NYOJ 105 九的余数

地址:http://acm.nyist.net/JudgeOnline/problem.php?pid=105

思路:大数求余,同NYOJ 205 求余数  

 1 #include<stdio.h>
 2 #include<string.h>
 3 char num[1000100];
 4 int main()
 5 {
 6     long int i;
 7     int n,temp,t;
 8     scanf("%d",&n);
 9     while(n--)
10     {
11         scanf("%s",num);
12         t=strlen(num);
13         for(temp=0,i=0;i<t;i++)
14         temp=(temp*10+num[i]-'0')%9;
15         printf("%d\n",temp%9);
16     }
17     return 0;
18 }

posted on 2012-08-19 09:31  mycapple  阅读(226)  评论(0编辑  收藏  举报

导航