HDU/HDOJ 2854 2009 Multi-University Training Contest 5 - Host by NUDT 数论
2011-09-21 14:41
211 查看
Central Meridian Number
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 210 Accepted Submission(s): 117
[align=left]Problem Description[/align]
A Central Meridian (ACM) Number N is a positive integer satisfies that given two positive integers A and B, and among A, B and N, we have
N | ((A^2)*B+1) Then N | (A^2+B)
Now, here is a number x, you need to tell me if it is ACM number or not.
[align=left]Input[/align]
The first line there is a number T (0<T<5000), denoting the test case number.
The following T lines for each line there is a positive number N (0<N<5000) you need to judge.
[align=left]Output[/align]
For each case, output “YES” if the given number is Kitty Number, “NO” if it is not.
[align=left]Sample Input[/align]
2 3 7
[align=left]Sample Output[/align]
YES NO Hint Hint X | Y means X is a factor of Y, for example 3 | 9; X^2 means X multiplies itself, for example 3^2 = 9; X*Y means X multiplies Y, for example 3*3 = 9.
[align=left]Source[/align]
2009 Multi-University Training Contest 5 - Host by NUDT
其实是标题党。。
这货就是预处理一下就可以了。。纯暴力
我的代码:
#include<stdio.h> bool flag[5005]; void init() { int i,j,n,x,y; for(n=1;n<=5000;n++) { for(i=1;i<=1000;i++) { for(j=1;j<=1000;j++) { x=i*i*j+1; y=i*i+j; if(x%n==0) { if(y%n!=0) { flag =true; goto loop; } } } } loop:; } } int main() { int n,t; init(); scanf("%d",&t); while(t--) { scanf("%d",&n); if(flag ) printf("NO\n"); else printf("YES\n"); } return 0; }
相关文章推荐
- HDU/HDOJ 2855 2009 Multi-University Training Contest 5 - Host by NUDT 矩阵二分幂
- 2009 Multi-University Training Contest 5 - Host by NUDT
- 2009 Multi-University Training Contest 10 - Host by NIT
- 【数论】2015 Multi-University Training Contest 1 1001
- Wireless Password [ 2009 Multi-University Training Contest 1 - Host by TJU ]
- 2014 Multi-University Training Contest 1/HDU4861_Couple doubi(数论/法)
- 2015 Multi-University Training Contest 7(HDOJ5379)
- hdu 3094 A tree game 2009 Multi-University Training Contest 18 - Host by ECNU
- Hdu4952 - Number Transformation - 数论(2014 Multi-University Training Contest 8)
- HDU 3015——Disharmony Trees(树状数组 2009 Multi-University Training Contest 12 - Host by FZU)
- hdoj 6058(2017 Multi-University Training Contest - Team 3) Kanade's sum
- 2017 Multi-University Training Contest 2 && HDOJ 6050 Funny Function 【思维+快速幂】
- 2017 Multi-University Training Contest - 第二场 07 If the starlight never fade (数论)
- (HDU 5728)2016 Multi-University Training Contest 1 PowMod(数论)
- 2017 Multi-University Training Contest 4 && HDOJ 6069 Counting Divisors 【区间筛法】
- 2017 Multi-University Training Contest 1 && HDOJ 6038 Function 【强连通找环】
- 2017 Multi-University Training Contest - Team 4 :Counting Divisors(数论:素数筛选+分解质因子+求因子数)
- 2009 Multi-University Training Contest 4 - Host by HDU
- 2014 Multi-University Training Contest 1/HDU4861_Couple doubi(数论/规律)
- Hdu4861 - Couple doubi - 数论(2014 Multi-University Training Contest 1-1001)