3 solutions
-
1
#include<bits/stdc++.h> using namespace std; int main(){ char f[105][105],tmp; int m,n; float wheat=0.0,grape=0.0,watermelon=0.0; cin>>m>>n; for(int i=1;i<=m;i++){ for(int j=1;j<=n;j++){ cin>>f[i][j]; } } for(int i=1;i<=m;i++){ for(int j=1;j<=n;j++){ cin>>tmp; float t; if(tmp=='N')t=1.0; else if(tmp=='B')t=1.2; else if(tmp=='R')t=1.5; else if(tmp=='G')t=2; if(f[i][j]=='*')wheat+=t; else if(f[i][j]=='#')grape+=t; else if(f[i][j]=='@')watermelon+=t; } } printf("%.1f %.1f %.1f",wheat,grape,watermelon); return 0; } -
-1
using namespace std; int main(){ int m,n; cin>>m>>n; string z[100]; for(int i=0;i<m;i++){ cin>>z[i]; } string t[100]; for(int i=0;i<m;i++){ cin>>t[i]; } double a=0.0,b=0.0,c=0.0; for(int i=0;i<m;i++){ for(int j=0;j<n;j++){ char x=z[i][j]; char y=t[i][j]; double l=1.0; if(y=='B')l=1.2; else if(y=='R')l=1.5; else if(y=='G')l=2.0; if(x=='*')a+=1.0*l; else if(x=='#')b+=1.0*l; else if(x=='@')c+=1.0*l; } } cout<<fixed<<setprecision(1)<<a<<" "<<b<<" "<<c; return 0; } -
-1
```#include<bits/stdc++.h> using namespace std; int main(){ int m,n; float putao=0.0,xiaomai=0.0,xigua=0.0; cin>>m>>n; char chary[m+5][n+5]; char inty[m+5][n+5]; for(int i=0;i<m;i++){ for(int j=0;j<n;j++){ cin>>chary[i][j]; } } for(int i=0;i<m;i++){ for(int j=0;j<n;j++){ cin>>inty[i][j]; } } for(int i=0;i<m;i++){ for(int j=0;j<n;j++){ if(chary[i][j]=='*'){ if(inty[i][j]=='N') xiaomai += 1.0; else if(inty[i][j]=='B') xiaomai += 1.2; else if(inty[i][j]=='R') xiaomai+=1.5; else if(inty[i][j]=='G') xiaomai+=2.0; } else if(chary[i][j]=='#'){ if(inty[i][j]=='N') putao += 1.0; else if(inty[i][j]=='B') putao += 1.2; else if(inty[i][j]=='R') putao += 1.5; else if(inty[i][j]=='R') putao += 2.0; } else if(chary[i][j]=='@'){ if(inty[i][j]=='N') xigua += 1.0; else if(inty[i][j]=='B') xigua += 1.2; else if(inty[i][j]=='R') xigua += 1.5; else if(inty[i][j]=='G') xigua += 2.0; } } } cout<<fixed<<setprecision(1); cout<<xiaomai<<" "<<putao<<" "<<xigua<<endl; return 0; } //我在本地测试没问题,不知道怎么了(时间,内存都没超)
- 1
Information
- ID
- 1087
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 8
- Tags
- (None)
- # Submissions
- 87
- Accepted
- 13
- Uploaded By