codevs 1488GangGang的烦恼

题目链接:http://codevs.cn/problem/1488/

写个高精度大数运算就行

 1 #include<cstdio>  
 2 #include<iostream>  
 3 #include<algorithm>
 4 #include<math.h> 
 5 #include<string.h>  
 6 #include<vector> 
 7 #include<queue>
 8 #include<iterator>
 9 #include<vector>
10 #include<set>
11 #define dinf 0x3f3f3f3f
12 typedef long long ll;
13 //const int Max=(1<<16)+10;
14 using namespace std;
15 
16 int IsP(int num)
17 {
18     if(num<=1)
19         return 0;
20     else
21     {
22         for(int i=2;i<=sqrt(num);i++)
23             if(num%i==0)
24                 return 0;
25     }
26     return 1;
27 }
28 
29 int main()
30 { 
31     int a[100005],i,j,num,count,k;
32     ll sum;
33     while(scanf("%d",&num)!=EOF)
34     {
35         a[0]=1;
36         count=1;
37         
38         for(i=1;i<=num;i++)
39         {
40             k=0;
41             for(j=0;j<count;j++)
42             {
43                 int temp=a[j]*i+k;
44                 a[j]=temp%10;
45                 k=temp/10;
46             }
47             while(k)
48             {
49                 a[count++]=k%10;
50                 k/=10;
51             }
52         }
53         sum=0;
54         for(i=count-1;i>=0;i--)
55             sum+=a[i];
56         if(IsP(sum))
57             printf("%dT
",sum);
58         else
59             printf("%dF
",sum);
60         
61     }
62     return 0;
63 }
原文地址:https://www.cnblogs.com/pter/p/5684547.html