結果
問題 | No.2541 Divide 01 String |
ユーザー |
|
提出日時 | 2023-11-24 21:31:49 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 14 ms / 2,000 ms |
コード長 | 350 bytes |
コンパイル時間 | 1,797 ms |
コンパイル使用メモリ | 192,888 KB |
最終ジャッジ日時 | 2025-02-17 23:47:42 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; ll const m = 998244353; int main () { int N; cin >> N; ll ans = 1; ll pre = -1; for (int i = 0; i < N; i ++) { char c; cin >> c; if (c == '1') { if (pre >= 0) { ans = (ans * (i - pre + 1)) % m; } pre = i; } } if (pre < 0) ans = 0; cout << ans << endl; }