Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 24   Accepted Submission(s) : 13

Font: Times New Roman | Verdana | Georgia

Font Size:  

Problem Description

集训-判断1到n连续n个数的最小公倍数与1到n-1连续n-1个数的最小公倍数是否相等

在学习完各类算法之后,yuna决定开始学习数论了。yuna神当然从最简单的最小公倍数学起喽~~~~~
定义 为1,2,…,n的最小公倍数,例如,B1 = 1,B2 = 2,B3 = 6,B4 = 12,B5 = 60,……。 
yuna想知道对于给出的任意整数n,Bn是否等于Bn-1。yuna当然是知道答案的喽,但是她想考考rexdf,这次rexdf囧了,请帮帮他吧!

Input

 
对于每组测试数据:包含一个整数n (2 ≤ n ≤ 1016)。

Output

 
第1行 如果Bn等于Bn-1则输出YES否则输出NO。

Sample Input

1 
6

Sample Output

YES

Author

Kuangbin

Source

developing schools contest 5

#include <stdio.h>
#define ll long long
ll gcd( ll a,ll b)
{
 return b==0?a:gcd(b,a%b);
}
int main( )
{
   int t;
   scanf("%d",&t);
   while(t--)
   {
   ll k;
   scanf("%I64d",&k);
   int d=0;
   for( ll i=2;i*i<=k;i++)
   {
  if(k%i==0)
  {
    int tt=gcd((k/i),i);
    if(tt==1)
    {
   d++;
   printf("YES\n");
   break;
    }
  }
   }
   if(d==0) printf("NO\n");
   }
   return 0;
}

相关文章:

  • 2021-05-29
  • 2021-10-19
  • 2022-12-23
  • 2022-12-23
  • 2021-08-28
  • 2021-04-23
  • 2021-08-01
  • 2022-01-03
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-04
相关资源
相似解决方案