2017萌新的ACM之旅参考代码
地址:https://vjudge.net/contest/180794#overview
A
1 #include <iostream> 2 3 using namespace std; 4 5 int main() 6 { 7 int a, b; 8 while(cin>>a>>b) 9 { 10 cout<<a+b<<endl; 11 } 12 return 0; 13 }
B
1 #include <iostream> 2 3 using namespace std; 4 5 int main() 6 { 7 int T, a, b; 8 cin>>T; 9 while(T--) 10 { 11 cin>>a>>b; 12 cout<<a+b<<endl; 13 } 14 return 0; 15 }
C
1 #include <iostream> 2 3 using namespace std; 4 5 int main() 6 { 7 int a, b; 8 while(cin>>a>>b) 9 { 10 if(a==0&&b==0)continue; 11 cout<<a+b<<endl; 12 } 13 return 0; 14 }
D
1 #include <iostream> 2 3 using namespace std; 4 5 int main() 6 { 7 int n, x, sum; 8 while(cin>>n&&n) 9 { 10 sum = 0; 11 for(int i = 0; i < n; i++) 12 { 13 cin>>x; 14 sum+=x; 15 } 16 17 cout<<sum<<endl; 18 } 19 return 0; 20 }
E
1 #include <iostream> 2 3 using namespace std; 4 5 int main() 6 { 7 int n, x, sum, T; 8 cin>>T; 9 while(T--) 10 { 11 sum = 0; 12 cin>>n; 13 for(int i = 0; i < n; i++) 14 { 15 cin>>x; 16 sum+=x; 17 } 18 19 cout<<sum<<endl; 20 } 21 return 0; 22 }
F
1 #include <iostream> 2 3 using namespace std; 4 5 int main() 6 { 7 int n, x, sum; 8 while(cin>>n) 9 { 10 sum = 0; 11 for(int i = 0; i < n; i++) 12 { 13 cin>>x; 14 sum+=x; 15 } 16 17 cout<<sum<<endl; 18 } 19 return 0; 20 }
G
1 #include <iostream> 2 3 using namespace std; 4 5 int main() 6 { 7 int a, b; 8 while(cin>>a>>b) 9 { 10 cout<<a+b<<endl<<endl; 11 } 12 return 0; 13 }
H
1 #include <iostream> 2 3 using namespace std; 4 5 int main() 6 { 7 int n, x, sum, T; 8 cin>>T; 9 sum = 0; 10 cin>>n; 11 for(int i = 0; i < n; i++) 12 { 13 cin>>x; 14 sum+=x; 15 } 16 cout<<sum<<endl; 17 T--; 18 while(T--) 19 { 20 sum = 0; 21 cin>>n; 22 for(int i = 0; i < n; i++) 23 { 24 cin>>x; 25 sum+=x; 26 } 27 28 cout<<endl<<sum<<endl; 29 } 30 return 0; 31 }