結果
| 問題 |
No.443 GCD of Permutation
|
| コンテスト | |
| ユーザー |
xuzijian629
|
| 提出日時 | 2018-11-07 02:12:17 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 879 bytes |
| コンパイル時間 | 1,681 ms |
| コンパイル使用メモリ | 193,252 KB |
| 最終ジャッジ日時 | 2025-01-06 15:42:35 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 18 WA * 10 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;
int main() {
string s;
cin >> s;
i64 sum = 0;
int cnt[10] = {};
for (char c: s) {
sum += c - '0';
cnt[c - '0']++;
}
i64 ans = 1;
if (sum % 9 == 0) {
ans *= 9;
} else if (sum % 3 == 0) {
ans *= 3;
}
for (int i = 0; i < 10; i++) {
if (cnt[i] == s.size()) {
cout << s << endl;
return 0;
}
}
if (cnt[0] + cnt[5] == s.size()) {
cout << 5 << endl;
return 0;
}
int e = 0;
for (int i = 0; i < 10; i += 2) {
e += cnt[i];
}
if (e == s.size()) {
if (cnt[0] + cnt[4] + cnt[8] == s.size()) {
ans *= 4;
} else {
ans *= 2;
}
}
cout << ans << endl;
}
xuzijian629