标签:
1 #include <iostream> 2 #include <string> 3 #include <vector> 4 5 using namespace std; 6 7 bool shout(int num) 8 { 9 if(num%7==0) 10 return true; 11 else 12 { 13 while(num>0) 14 { 15 int a=num%10; 16 if(a==7) 17 return true; 18 num=num/10; 19 } 20 return false; 21 } 22 23 } 24 int main() 25 { 26 int n; 27 cin>>n; 28 for(int i=0;i<n;i++) 29 { 30 string s; 31 cin>>s; 32 if(s=="Faster") 33 { 34 int num; 35 cin>>num; 36 vector<int> v(num); 37 for(int i=0;i<num;i++) 38 { 39 int a; 40 cin>>a; 41 v[i]=a; 42 } 43 int temp=v[0]; 44 // cout<<temp<<endl; 45 for(int i=0;i<=num-1;i++) 46 { 47 if(temp>v[i]) 48 temp=v[i]; 49 } 50 51 cout<<temp<<endl; 52 53 } 54 else if(s=="Higher"||s=="Stronger") 55 { 56 int num; 57 cin>>num; 58 vector<int> v(num); 59 for(int i=0;i<num;i++) 60 { 61 int a; 62 cin>>a; 63 v[i]=a; 64 } 65 int temp=v[0]; 66 67 for(int i=0;i<=num-1;i++) 68 { 69 if(temp<v[i]) 70 temp=v[i]; 71 } 72 cout<<temp<<endl; 73 } 74 75 } 76 return 0; 77 }
1 #include <iostream> 2 #include <vector> 3 4 using namespace std; 5 6 bool shout(int num) 7 { 8 if(num%7==0) 9 return true; 10 else 11 { 12 while(num>0) 13 { 14 int a=num%10; 15 if(a==7) 16 return true; 17 num=num/10; 18 } 19 return false; 20 } 21 22 } 23 int main() 24 { 25 int n; 26 cin>>n; 27 for(int i=0;i<n;i++) 28 { 29 int num; 30 cin>>num; 31 vector<int> v; 32 for(int i =0;i<=num;i++) 33 { 34 int temp; 35 cin>>temp; 36 v.push_back(temp); 37 } 38 if(num==0) 39 cout<<0<<endl; 40 else 41 { 42 for(int i =0;i<=num-1;i++) 43 { 44 if(i==num-1) 45 cout<<v[i]*(num-i); 46 else 47 cout<<v[i]*(num-i)<<" "; 48 } 49 cout<<endl; 50 } 51 52 } 53 return 0; 54 }
1 #include <iostream> 2 3 4 using namespace std; 5 6 bool shout(int num) 7 { 8 if(num%7==0) 9 return true; 10 else 11 { 12 while(num>0) 13 { 14 int a=num%10; 15 if(a==7) 16 return true; 17 num=num/10; 18 } 19 return false; 20 } 21 22 } 23 int main() 24 { 25 int n; 26 cin>>n; 27 for(int i=0;i<n;i++) 28 { 29 int p,num=0,p1=0; 30 cin>>p; 31 while(p1!=p) 32 { 33 num++; 34 bool b1=shout(num); 35 bool b2=shout(num+1); 36 if(b1&&!b2) 37 { 38 p1++; 39 if(p1!=p) 40 p1=0; 41 42 } 43 else if(b1&&b2) 44 p1++; 45 } 46 cout<<num-p+1<<endl; 47 48 } 49 return 0; 50 }
1 #include <iostream> 2 #include <string> 3 4 using namespace std; 5 6 void beat(int s,int d) 7 { 8 int large=s,small=s-d; 9 bool b=true; 10 while(large+small!=s) 11 { 12 large--; 13 small=large-d; 14 if(small<0) 15 { 16 b=false; 17 18 break; 19 } 20 } 21 if(b) 22 cout<<large<<" "<<small<<endl; 23 else 24 cout<<"impossible"<<endl; 25 26 } 27 int main() 28 { 29 int n; 30 cin>>n; 31 for(int i=0;i<n;i++) 32 { 33 string s_1,s_2,s1,s2; 34 int l1,l2; 35 while(true) 36 { cin>>l1; 37 if(l1<6&&l1>0) 38 break; 39 } 40 for(int i=0;i<l1;i++) 41 { 42 cin>>s1; 43 s_1.push_back(s1[0]); 44 } 45 while(true) 46 { cin>>l2; 47 if(l2<6&&l2>0) 48 break; 49 } 50 51 for(int i=0;i<l2;i++) 52 { 53 cin>>s2; 54 s_2.push_back(s2[0]); 55 } 56 if(s_1==s_2) 57 cout<<"SAME"<<endl; 58 else 59 cout<<"DIFFERENT"<<endl; 60 61 } 62 return 0; 63 }
1 #include <iostream> 2 #include <string> 3 4 using namespace std; 5 6 void beat(int s,int d) 7 { 8 int large=s,small=s-d; 9 bool b=true; 10 while(large+small!=s) 11 { 12 large--; 13 small=large-d; 14 if(small<0) 15 { 16 b=false; 17 18 break; 19 } 20 } 21 if(b) 22 cout<<large<<" "<<small<<endl; 23 else 24 cout<<"impossible"<<endl; 25 26 } 27 int main() 28 { 29 int n; 30 cin>>n; 31 for(int i=0;i<n;i++) 32 { 33 int s,d; 34 cin>>s>>d; 35 beat(s,d); 36 } 37 return 0; 38 }
1 #include <iostream> 2 #include <string> 3 4 using namespace std; 5 6 void whether(int a,int b) 7 { if(a>=b) 8 cout<<"MMM BRAINS"<<endl; 9 else 10 cout<<"NO BRAINS"<<endl; 11 12 } 13 int main() 14 { 15 int n; 16 cin>>n; 17 for(int i=0;i<n;i++) 18 { 19 int x,y; 20 cin>>x>>y; 21 whether(x,y); 22 } 23 return 0; 24 }
1 #include <iostream> 2 3 4 using namespace std; 5 //经典整数倒转函数 6 int zhuan(int x) 7 { 8 int a=0; 9 10 while (x>0) 11 { 12 a=a*10+x%10; 13 x/=10; 14 } 15 return a; 16 } 17 int main() 18 { 19 int n; 20 cin>>n; 21 for(int i=0;i<n;i++) 22 { 23 int x,y; 24 cin>>x>>y; 25 cout<<zhuan(zhuan(x)+zhuan(y))<<endl; 26 } 27 return 0; 28 }
1 #include <iostream> 2 #include<vector> 3 #include<iomanip> 4 using namespace std; 5 int main() 6 { 7 int c; 8 cin>>c; 9 for(int i=0;i<c;i++) 10 { 11 int n; 12 cin>>n; 13 vector<int> v(n); 14 int sum=0,num=0; 15 for(int j=0;j<n;j++) 16 { 17 int g; 18 cin>>g; 19 v[j]=g; 20 21 sum+=g; 22 } 23 float avg=(float)sum/n; 24 // cout<<avg<<endl; 25 for(int j=0;j<n;j++) 26 { 27 // cout<<v[j]<<endl; 28 if((float)v[j]>avg) 29 num++; 30 } 31 //cout<<num<<endl; 32 float per=(float)num/n; 33 cout<<fixed<<setprecision(3)<<100*per<<"%"<<endl; 34 } 35 }
标签:
原文地址:http://www.cnblogs.com/xiaoyesoso/p/4265176.html