标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4793 Accepted Submission(s): 2672
思路:1.九余数定理 一个数的n的树根=(n-1)%9+1
2.N个整数的树根的乘机总值=每个项元素的树根的乘积
3.分步求余
#include<cstdio> #include<cmath> int main() { int n; while(scanf("%d",&n)&&n) { int m=n; int i; int ans=1; m=(m-1)%9+1;//先把底数m求树根,根据 N个整数的乘积带的树根=每项元素的树根的乘积 for(i=1;i<=n;i++) ans=(ans*m-1)%9+1;//分步求余 printf("%d\n",ans); } }
标签:
原文地址:http://www.cnblogs.com/orchidzjl/p/4265334.html