CCCherry

导航

UCF Local Programming Contest 2012(Practice)补题

Clean Up the Powers that Be

主要是输出格式上的问题

 1 #include <iostream>
 2 #include <cstring>
 3 using namespace std;
 4 int main(){
 5     long long t,s[10005];
 6     cin>>t;
 7     int p=0;
 8     while(t--){
 9         p++;
10         memset(s,0,sizeof(s));
11         int n;
12         cin>>n;
13         for(int i=0;i<n;i++){
14             int a,b;
15             cin>>a>>b;
16             s[a]+=b;
17         }
18         cout<<"Prime Factorization #"<<p<<":"<<endl;
19         for(int i=1;i<10005;i++){
20             //cout<<s[i]<<" ";
21             if(s[i]!=0){
22                 //cout<<s[i]<<" ";
23                 int k=i;
24                 while(k!=0){
25                     k/=10;
26                     cout<<" ";
27                 }
28                 cout<<s[i];
29             }
30         }
31         cout<<endl;
32         for(int i=1;i<10005;i++){
33             if(s[i]!=0){
34                 cout<<i;
35                 int k=s[i];
36                 while(k!=0){
37                     k/=10;
38                     cout<<" ";
39                 }
40             }
41         }
42         cout<<endl<<endl;
43     }
44 }

 

posted on 2020-03-06 21:24  CCCherry  阅读(205)  评论(0编辑  收藏  举报