結果
問題 |
No.3278 Avoid Division
|
ユーザー |
|
提出日時 | 2025-09-19 22:42:15 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,032 bytes |
コンパイル時間 | 1,787 ms |
コンパイル使用メモリ | 202,084 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-19 22:42:21 |
合計ジャッジ時間 | 4,980 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 24 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:34:14: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘std::vector<std::__cxx11::basic_string<char> >::size_type’ {aka ‘long unsigned int’} [-Wformat=] 34 | printf("%d\n", ans.size()); | ~^ ~~~~~~~~~~ | | | | int std::vector<std::__cxx11::basic_string<char> >::size_type {aka long unsigned int} | %ld
ソースコード
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; typedef long long ll; typedef pair<ll, ll> pli; const int N = 2000086, MOD = 998244353, INF = 0x3f3f3f3f; ll res; int n, m, cnt, w[N]; string op[200]; int main() { cin >> n; vector<string> ans; for (int i = 1; i < n + 1; i++) cin >> op[i] >> w[i]; bool f = 0; for (int i = 1; i < n + 1; i++) { if (op[i] == "+") { if (!f) ans.push_back("add a a A[" + to_string(i) + "]"); else { ans.push_back("mul c b A[" + to_string(i) + "]"); ans.push_back("add a a c"); } } else if (op[i] == "*") { ans.push_back("mul a a A[" + to_string(i) + "]"); } else { if (f) ans.push_back("mul b b A[" + to_string(i) + "]"); else f = 1, ans.push_back("add b b A[" + to_string(i) + "]"); } } if (f) ans.push_back("div a a b"); printf("%d\n", ans.size()); for (auto u : ans) puts(u.c_str()); return 0; }