結果

問題 No.9001 標準入出力の練習問題(テスト用)
ユーザー harurunharurun
提出日時 2022-07-15 19:04:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 1,058 bytes
コンパイル時間 2,038 ms
コンパイル使用メモリ 203,096 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-09-09 21:33:19
合計ジャッジ時間 2,470 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

char c;
stack<int> s;

void mul(){int a=s.top();s.pop();int b=s.top();s.pop();s.push(a*b);}
void div(){int a=s.top();s.pop();int b=s.top();s.pop();s.push(b/a);}
void add(){int a=s.top();s.pop();int b=s.top();s.pop();s.push(a+b);}
void sub(){int a=s.top();s.pop();int b=s.top();s.pop();s.push(b-a);}
bool eq0(){int a=s.top();s.pop();return a==0;}

int main(){
  s.push(0);
  label1:
  s.push(10);mul();c=getchar();s.push(c);s.push(s.top());s.push(32);sub();if(eq0()){goto label2;}s.push(48);sub();add();goto label1;
  label2:
  s.pop();s.push(10);div();s.push(0);
  label3:
  s.push(10);mul();c=getchar();s.push(c);s.push(s.top());s.push(10);sub();
  if(eq0()){goto label4;}s.push(48);sub();add();goto label3;
  label4:
  s.pop();s.push(10);div();add();printf("%d",s.top());s.pop();s.push(32);printf("%c",s.top());
  label5:
  c=getchar();s.push(c);s.push(s.top());s.push(10);sub();if(eq0()){goto label6;}printf("%c",s.top());s.pop();
  goto label5;
  label6:
  s.push(10);printf("%c",s.top());s.pop();exit(0);
}
0