[解题报告]训练日记5

几个比较**(ex)的数学题

HDU3903

这个题比较好,就是判断这个式子是否是有理数

我本来以为cos都是有理数,只判断分母即可,但是

给一个大佬的题解吧(的确不会做的数学题

在这里插入图片描述

#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<algorithm> 
#include<cmath>
#include<vector>
#include<map>
using namespace std;
typedef long long LL;
#define PI acos(-1)
#define fin freopen("data.txt","r",stdin)
#define INF 2147483647
#define eps 1e-7
#define L 100005
#define Fo(i,a,b) for(LL i=(a),_=(b); i<=_; i++)
#define Ro(i,b,a) for(LL i=(b),_=(a); i>=_; i--)
#define Ms(a,b) memset((a),(b),sizeof(a))
#define _ceil(_,__) (_+(__-1))/__
inline LL read() {
    
    
	LL x = 0, f = 1;char c = getchar();
	while (!isdigit(c)) {
    
     if (c == '-')f = -f;c = getchar(); }
	while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48ll), c = getchar();
	return x * f;
}

LL T, a, b, c, n, m, k , p , aq , bq , cq;

int main() {
    
    
//	fin;
	T = read();
	while (T--) {
    
    
		a = read(); b = read(); c = read();
		p = read(); p = read(); p = read();
		n = pow(2 * a * b, 2) - pow(a * a + b * b - c * c, 2);
		m = pow(2 * c * b, 2) - pow(c * c + b * b - a * a, 2);
		k = pow(2 * a * c, 2) - pow(a * a + c * c - b * b, 2);
		aq = sqrt(n); bq = sqrt(m); cq = sqrt(k);
		if (aq*aq==n&&bq*bq==m&&cq*cq==k)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

HDU6433

提前计算答案的位数:在这里插入图片描述
本质就是用数组把每个数字存下来然后模拟乘法

#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<algorithm> 
#include<cmath>
#include<vector>
#include<map>
using namespace std;
typedef long long LL;
#define PI acos(-1)
#define fin freopen("data.txt","r",stdin)
#define INF 2147483647
#define eps 1e-7
#define L 100005
#define Fo(i,a,b) for(LL i=(a),_=(b); i<=_; i++)
#define Ro(i,b,a) for(LL i=(b),_=(a); i>=_; i--)
#define Ms(a,b) memset((a),(b),sizeof(a))
#define _ceil(_,__) (_+(__-1))/__
inline LL read() {
    
    
	LL x = 0, f = 1;char c = getchar();
	while (!isdigit(c)) {
    
     if (c == '-')f = -f;c = getchar(); }
	while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48ll), c = getchar();
	return x * f;
}

LL T, n , ans[2005] , len;

int main() {
    
    
//	fin;
	T = read();
	while (T--) {
    
    
		Ms(ans, 0);
		n = read();
		len = n * 0.3010299;
		ans[0] = 1;
		while (n--) {
    
    
			Ro(i, len, 0) {
    
    
				ans[i + 1] += ans[i] / 5;
				ans[i] = ans[i] * 2 % 10;
			}
		}
		Ro(i, len, 0)
			printf("%lld", ans[i]);
		printf("\n");
	}
	return 0;
}

CF1042A

人数最多一定是把后来的m个人放到目前人数最大的上面(即输入的最大值

人数最少(可能)是越平均越好,为什么是“可能”呢,因为如果你的平均值比现在的最大值还小的话人数一定不是最多的啊(就是类似于最大值最小呗

#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<algorithm> 
#include<cmath>
#include<vector>
#include<map>
using namespace std;
typedef long long LL;
#define PI acos(-1)
#define fin freopen("data.txt","r",stdin)
#define INF 2147483647
#define eps 1e-7
#define L 100005
#define Fo(i,a,b) for(LL i=(a),_=(b); i<=_; i++)
#define Ro(i,b,a) for(LL i=(b),_=(a); i>=_; i--)
#define Ms(a,b) memset((a),(b),sizeof(a))
#define _ceil(_,__) (_+(__-1))/__
inline LL read() {
    
    
	LL x = 0, f = 1;char c = getchar();
	while (!isdigit(c)) {
    
     if (c == '-')f = -f;c = getchar(); }
	while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48ll), c = getchar();
	return x * f;
}

LL n, num[105], m, sum, maxx = -1;

int main() {
    
    
//	fin;
	n = read(); m = read();
	Fo(i, 1, n) num[i] = read(), sum += num[i], maxx = max(maxx, num[i]);
	printf("%lld %lld", max(_ceil((sum + m), n),maxx), maxx + m);
	return 0;
}

HDU2035

快速幂裸题,对1000取模

#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
typedef long long LL;
#define PI acos(-1)
#define fin freopen("data.txt","r",stdin)
#define INF 2147483647
#define eps 1e-7
#define L 100005
#define Fo(i,a,b) for(LL i=(a),_=(b); i<=_; i++)
#define Ro(i,b,a) for(LL i=(b),_=(a); i>=_; i--)
#define Ms(a,b) memset((a),(b),sizeof(a))
inline LL read() {
    
    
	LL x=0,f=1;char c=getchar();
    while(!isdigit(c)) {
    
    if(c=='-')f=-f;c=getchar();}
    while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48ll),c=getchar();
    return x*f;
}

LL A , B , k=1000;

LL qpow(LL a , LL b) {
    
    
	if(b==0)
		return 1;
	LL c = qpow(a,b>>1)%k;
	if(b&1)
		return c*c%k*a%k;
	return c*c%k;
}

int main() {
    
    
	//fin;
	while(1) {
    
    
		A=read(); B=read();
		if(A==0&&B==0)
			break;
		printf("%lld\n",qpow(A,B)%k);
	}
	return 0;
} 

再记录一个上下取整的写法(代码里宏定义也有
在这里插入图片描述

这次的题量虽然少,但是可见数学是真的弱

啥时候能有时间系统复习以下呢

猜你喜欢

转载自blog.csdn.net/cls1277/article/details/110674544
今日推荐