結果
問題 |
No.3278 Avoid Division
|
ユーザー |
|
提出日時 | 2025-09-21 12:05:22 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,058 bytes |
コンパイル時間 | 834 ms |
コンパイル使用メモリ | 75,900 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-21 12:05:33 |
合計ジャッジ時間 | 3,680 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 24 |
ソースコード
#include<iostream> #include<vector> #include<sstream> #include<cassert> using namespace std; int N; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin>>N; vector<string>ans; // a/b bool b=false; for(int i=1;i<=N;i++) { char op;int a;cin>>op>>a; if(op=='+') { if(b) { { stringstream ss; ss<<"mul c b A["<<i<<"]"; ans.push_back(ss.str()); } { stringstream ss; ss<<"add a a c"; ans.push_back(ss.str()); } } else { stringstream ss; ss<<"add a a A["<<i<<"]"; ans.push_back(ss.str()); } } else if(op=='*') { stringstream ss; ss<<"mul a a A["<<i<<"]"; ans.push_back(ss.str()); } else { if(!b) { stringstream ss; ss<<"add b b A["<<i<<"]"; ans.push_back(ss.str()); b=true; } else { stringstream ss; ss<<"mul b b A["<<i<<"]"; ans.push_back(ss.str()); } } } if(b) { stringstream ss; ss<<"div a a b"; ans.push_back(ss.str()); } cout<<ans.size()<<"\n"; for(string s:ans)cout<<s<<"\n"; }