結果
問題 |
No.2541 Divide 01 String
|
ユーザー |
|
提出日時 | 2024-01-24 20:35:30 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 9 ms / 2,000 ms |
コード長 | 461 bytes |
コンパイル時間 | 2,014 ms |
コンパイル使用メモリ | 195,056 KB |
最終ジャッジ日時 | 2025-02-18 22:34:12 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include<bits/stdc++.h> using namespace std; #define int long long const int mod = 998244353; signed main(){ int n; cin >> n; string s; cin >> s; vector<int> a; for(int i = 0;i < n;i++) if(s[i] == '1') a.push_back(i); if((int)a.size() == 0) cout << 0; else if((int)a.size() == 1) cout << 1; else{ int ans = 1; for(int j = 0;j < (int)a.size() - 1;j++){ ans *= (a[j + 1] - a[j] + 1); ans %= mod; } cout << ans % mod << endl; } }