@geek-sjl
2018-09-25T15:27:17.000000Z
字数 1113
阅读 530
#include <cstdio>int count(int n){int sum=0;for(int i=1;i<=n-1;i++){sum+=i;}printf("%d\n",sum%n);}int main(){for(int i=1;i<=10000;i++){count(i);}return 0;}
No matter n is odd or even ,we could get that
#include <cstdio>#include <cmath>long long count(int i,int n){long long sum=0;for(int t=1;t<=n-1;t++){sum+=pow(t,i);sum%=n;}return sum;}int main(){for(int n=2;n<=15;n++){for(int i=2;i<=n-1;i++){printf("%4d ",count(i,n));}printf("\n");}return 0;}
Here is the output
Because the result of pow() is too large,n couldn't over 15.
2
2 0
0 0 4
1 3 1 3
0 0 0 0 6
4 0 4 0 4 0
6 0 6 0 6 0 6
5 5 3 5 5 5 3 5
0 0 0 0 0 0 0 0 10
2 0 2 0 2 0 2 0 2 0
0 0 0 0 0 0 0 0 0 0 12
7 7 7 7 5 7 7 7 7 7 5 7
10 0 7 0 10 0 7 0 10 0 7 0 9
It is not finished,emm....give me more time...,