結果
問題 | No.2593 Reorder and Mod 120 |
ユーザー |
|
提出日時 | 2023-12-22 18:35:06 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 843 bytes |
コンパイル時間 | 1,917 ms |
コンパイル使用メモリ | 199,220 KB |
最終ジャッジ日時 | 2025-02-18 13:13:38 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 22 WA * 4 |
ソースコード
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") using namespace std; random_device rnd; mt19937 mt(rnd()); int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); int N; cin >> N; string S; cin >> S; int mod3 = 0; vector<int> cnt(10, 0); for(char c : S) { cnt[c - '0']++; mod3 = (mod3 + c - '0') % 3; } if(mod3 == 0) { mod3 += 3; } vector<bool> can(120, false); while(mod3 < 120000) { int tmp = mod3; vector<int> c(10, 0); while(tmp > 0) { c[tmp % 10]++; tmp /= 10; } bool fn = true; for(int i = 0; i < 10; i++) { if(c[i] > cnt[i]) { fn = false; } } if(fn) { can[mod3 % 120] = true; } mod3 += 3; } cout << accumulate(can.begin(), can.end(), 0) << '\n'; return 0; }