結果
問題 |
No.1092 modular arithmetic
|
ユーザー |
![]() |
提出日時 | 2025-06-05 00:22:43 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 34 ms / 2,000 ms |
コード長 | 728 bytes |
コンパイル時間 | 3,129 ms |
コンパイル使用メモリ | 276,936 KB |
実行使用メモリ | 6,272 KB |
最終ジャッジ日時 | 2025-06-05 00:22:49 |
合計ジャッジ時間 | 5,866 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; #include <atcoder/modint> using mint = atcoder::modint; int main() { cin.tie(nullptr)->sync_with_stdio(false); int p, n; cin >> p >> n; mint::set_mod(p); vector<int> a(n); rep(i, n) cin >> a[i]; string s; cin >> s; mint ans = a[0]; rep(i, n - 1) { if (s[i] == '+') ans += a[i + 1]; if (s[i] == '-') ans -= a[i + 1]; if (s[i] == '*') ans *= a[i + 1]; if (s[i] == '/') ans /= a[i + 1]; } cout << ans.val() << '\n'; return 0; }