2017杭电多校第七场1005 Euler theorem(勉强数论)HDU 6124

来源:互联网 发布:轩辕剑披风进阶数据 编辑:程序博客网 时间:2024/04/30 19:43

Euler theorem

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 518    Accepted Submission(s): 415


Problem Description
HazelFan is given two positive integers a,b, and he wants to calculate amodb. But now he forgets the value of b and only remember the value of a, please tell him the number of different possible results.
 

Input
The first line contains a positive integer T(1T5), denoting the number of test cases.
For each test case:
A single line contains a positive integer a(1a109).
 

Output
For each test case:
A single line contains a nonnegative integer, denoting the answer.
 

Sample Input
213
 

Sample Output
23
 

Source
2017 Multi-University Training Contest - Team 7
 

Recommend

liuyiding   |   We have carefully selected several similar problems for you:  6132 6131 6130 6129 6128 

题目大意:给你 a ,问 a 对所有数取模后的所有结果有多少个。

解题思路:每一个数取模能得到的数就是0~( a + 1 )/2加上它本身.

AC代码:

#include<iostream>#include<cstdio>using namespace std;int main(){int t;scanf("%d",&t);while(t--){int a;scanf("%d",&a);int ans;if(a%2==0)ans=a/2+1;else ans=a/2+2;printf("%d\n",ans);}return 0;}


原创粉丝点击