hdu6124 Euler theorem 2017多校1005签到题

来源:互联网 发布:树莓派开源人工智能 编辑:程序博客网 时间:2024/05/19 03:28

http://acm.split.hdu.edu.cn/showproblem.php?pid=6124

题意:给定一个数a,求a%b(b为正整数)有多少种可能。

题解:题目说欧拉,差点被骗了,还去把答案和欧拉函数打表出来比对。。。其实就是取b=(a+1)/2,(a+1)/2+1,...,a,可以发现a%b是连续的,并且涵盖了b∈[1,a/2]。最后加上a本身,就是(a+1)/2+1种了。

代码:

#include<bits/stdc++.h>#define debug cout<<"aaa"<<endl#define d(a) cout<<a<<endl#define mem(a,b) memset(a,b,sizeof(a))#define LL long long#define lson l,mid,root<<1#define rson mid+1,r,root<<1|1#define MIN_INT (-2147483647-1)#define MAX_INT 2147483647#define MAX_LL 9223372036854775807i64#define MIN_LL (-9223372036854775807i64-1)using namespace std;const int N = 100000 + 5;const int mod = 1000000000 + 7;const double eps = 1e-8;int main(){int t,n;scanf("%d",&t);while(t--){scanf("%d",&n);printf("%d\n",(n+1)/2+1);}return 0;}