2179: Dividable
| Result | TIME Limit | MEMORY Limit | Run Times | AC Times | JUDGE |
|---|---|---|---|---|---|
| 3s | 8192K | 466 | 198 | Standard |
For two integer n and k(0 < n,k <100000000). Tell if n^k-1 is dividable by (n-1)^2.
This problem contains multiple input, each of which contains two number n and k.
Print "yes" if n^k-1 is dividable by (n-1)^2, otherwise print no.
Sample Input
3 4 3 3
Sample Output
yes no
Problem Source: evil
#include<stdio.h>
int main()
{
int n,k;
while(scanf("%d%d",&n,&k)!=EOF)
{
if(k%(n-1)==0)
printf("yes/n");
else printf("no/n");
}
return 0;
}
//n^k-1=(n-1+1)^k-1 多项式展开公式
本文介绍了一个简单的算法,用于判断对于任意两个整数n和k(0<n,k<100000000),n^k-1是否能被(n-1)^2整除。该算法通过输入n和k,利用多项式展开公式进行快速判断,并提供了示例输入输出。
1719

被折叠的 条评论
为什么被折叠?



