結果
問題 | No.443 GCD of Permutation |
ユーザー | Pachicobue |
提出日時 | 2017-05-05 15:53:11 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 3,731 bytes |
コンパイル時間 | 1,641 ms |
コンパイル使用メモリ | 171,568 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-14 00:06:21 |
合計ジャッジ時間 | 2,580 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 1 ms
5,248 KB |
testcase_03 | AC | 1 ms
5,248 KB |
testcase_04 | AC | 2 ms
5,248 KB |
testcase_05 | AC | 2 ms
5,248 KB |
testcase_06 | AC | 2 ms
5,248 KB |
testcase_07 | AC | 2 ms
5,248 KB |
testcase_08 | AC | 2 ms
5,248 KB |
testcase_09 | AC | 2 ms
5,248 KB |
testcase_10 | AC | 2 ms
5,248 KB |
testcase_11 | AC | 2 ms
5,248 KB |
testcase_12 | AC | 2 ms
5,248 KB |
testcase_13 | AC | 2 ms
5,248 KB |
testcase_14 | AC | 2 ms
5,248 KB |
testcase_15 | AC | 2 ms
5,248 KB |
testcase_16 | AC | 2 ms
5,248 KB |
testcase_17 | AC | 2 ms
5,248 KB |
testcase_18 | AC | 2 ms
5,248 KB |
testcase_19 | AC | 2 ms
5,248 KB |
testcase_20 | AC | 3 ms
5,248 KB |
testcase_21 | AC | 2 ms
5,248 KB |
testcase_22 | AC | 2 ms
5,248 KB |
testcase_23 | AC | 2 ms
5,248 KB |
testcase_24 | AC | 2 ms
5,248 KB |
testcase_25 | AC | 2 ms
5,248 KB |
testcase_26 | AC | 2 ms
5,248 KB |
testcase_27 | AC | 2 ms
5,248 KB |
testcase_28 | AC | 2 ms
5,248 KB |
testcase_29 | AC | 2 ms
5,248 KB |
testcase_30 | AC | 2 ms
5,248 KB |
testcase_31 | AC | 2 ms
5,248 KB |
ソースコード
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--) #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i <= (n); i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) #define pb push_back #define mp make_pair #define fst first #define snd second #define show(x) cout << #x << " = " << x << endl #define chmin(x, y) x = min(x, y) #define chmax(x, y) x = max(x, y) #define pii pair<int, int> #define vi vector<int> using namespace std; template <class S, class T> ostream& operator<<(ostream& o, const pair<S, T>& p) { return o << "(" << p.first << "," << p.second << ")"; } template <class T> ostream& operator<<(ostream& o, const vector<T>& vc) { o << "sz = " << vc.size() << endl << "["; for (const T& v : vc) o << v << ","; o << "]"; return o; } using ll = long long; constexpr ll MOD = 1000000007; constexpr int MAX = 10001; int digits[MAX]; int num[10]; int mod3[3]; inline int convert(const char c) { return c - '0'; } int main() { string str; cin >> str; const int n = str.size(); int sum = 0; rep(i, n) { digits[i] = convert(str[i]); sum += convert(str[i]); mod3[convert(str[i]) % 3]++; num[convert(str[i])]++; } sort(digits, digits + n); if (digits[0] == digits[n - 1]) { rep(i, n) { cout << digits[i]; } cout << endl; return 0; } int prime = 1; while (num[1] == 0 and num[3] == 0 and num[5] == 0 and num[7] == 0 and num[9] == 0) { num[1] = num[2]; num[2] = num[4]; num[3] = num[6]; num[4] = num[8]; prime *= 2; } while (num[1] == 0 and num[2] == 0 and num[3] == 0 and num[4] == 0 and num[6] == 0 and num[7] == 0 and num[8] == 0 and num[9] == 0) { num[1] = num[5]; prime *= 5; } if (max({num[1], num[2], num[3], num[4], num[5], num[6], num[7], num[8]}) == 0) { if (num[9] % 3 == 0) { prime *= 81; } else { if (sum % 3 == 0) { prime *= 3; if (sum % 9 == 0) { prime *= 3; } } } } else if (max(mod3[0], mod3[1]) == 0 or max(mod3[1], mod3[2]) == 0 or max(mod3[0], mod3[2]) == 0) { int i = 0; rep(j, n) { if (j % 3 == 0) { i = (i + digits[j]) % 27; } else if (j % 3 == 1) { i = (i + 10 * digits[j]) % 27; } else { i = (i + 19 * digits[j]) % 27; } } if (i % 27 == 0) { prime *= 27; } else { if (sum % 3 == 0) { prime *= 3; if (sum % 9 == 0) { prime *= 3; } } } } else { if (sum % 3 == 0) { prime *= 3; if (sum % 9 == 0) { prime *= 3; } } } if (num[1] == 0 and num[2] == 0 and num[3] == 0 and num[4] == 0 and num[5] == 0 and num[6] == 0 and num[8] == 0 and num[9] == 0) { if (n % 6 == 0) { prime *= 7; } } else if (num[0] == 0 and num[2] == 0 and num[3] == 0 and num[4] == 0 and num[5] == 0 and num[6] == 0 and num[7] == 0 and num[9] == 0) { if (n % 6 == 0) { prime *= 7; } } else if (num[0] == 0 and num[1] == 0 and num[3] == 0 and num[4] == 0 and num[5] == 0 and num[6] == 0 and num[7] == 0 and num[8] == 0) { if (n % 6 == 0) { prime *= 7; } } cout << prime << endl; return 0; }