Submission #00081
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | #include<bits/stdc++.h> using namespace std; int main(){ int n; while (cin>>n,n){ string str[20]; queue< int >siki[10]; char enzan[10]; int maxs=0; for ( int i=0;i<n;i++){ cin>>str[i]; } if (n==1)cout<<str[0]<<endl; else { int cnt; for ( int i=0;i<n;i++){ cnt=0; for ( int j=0;j<20;j++){ if (str[i][j]== '.' ){ cnt++; maxs=max(cnt,maxs); } else { if (str[i][j]>= '0' && str[i][j]<= '9' ){ siki[cnt-1].push(str[i][j]- '0' ); } else { enzan[cnt]=str[i][j]; } break ; } } } maxs--; int temp; for ( int i=maxs;i>=1;i--){ if (enzan[i]== '+' ){ temp=0; while (!siki[i].empty()){ temp+=siki[i].front(); siki[i].pop(); } } else if (enzan[i]== '*' ){ temp=1; while (!siki[i].empty()){ temp*=siki[i].front(); siki[i].pop(); } } siki[i-1].push(temp); } int ans; if (enzan[0]== '+' ){ ans=0; while (!siki[0].empty()){ ans+=siki[0].front();siki[0].pop(); } } if (enzan[0]== '*' ){ ans=1; while (!siki[0].empty()){ ans*=siki[0].front();siki[0].pop(); } } cout<<ans<<endl; } } } |
ステータス
項目 | データ |
---|---|
問題 | 0003 - ICPC計算機 |
ユーザー名 | ei1501 |
投稿日時 | 2016-03-30 14:55:59 |
言語 | C++11 |
状態 | Wrong Answer |
得点 | 0 |
ソースコード長 | 1241 Byte |
最大実行時間 | 15 ms |
最大メモリ使用量 | 700 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 0 / 20 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
C1 | WA | 13 ms | 476 KB |
1
|
C2 | WA | 15 ms | 700 KB |
1
|
C3 | WA | 12 ms | 668 KB |
1
|
C4 | WA | 12 ms | 508 KB |
1
|