結果
| 問題 |
No.1632 Sorting Integers (GCD of M)
|
| コンテスト | |
| ユーザー |
Kude
|
| 提出日時 | 2021-07-30 22:11:36 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,497 bytes |
| コンパイル時間 | 4,077 ms |
| コンパイル使用メモリ | 253,068 KB |
| 最終ジャッジ日時 | 2025-01-23 11:54:45 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 23 WA * 36 |
ソースコード
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n)for (int i = 0; i < int(n); ++i)
#define rrep(i,n)for (int i = int(n)-1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
template<class T> void chmax(T& a, const T& b) {a = max(a, b);}
template<class T> void chmin(T& a, const T& b) {a = min(a, b);}
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using mint = modint1000000007;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
int c[11] = {};
rep(i, 9) cin >> c[i + 1];
int cs = 0;
rep(i, 10) cs += c[i] > 0;
if (cs == 1) {
rep(i, 10) if (c[i]) {
cout << ((mint(10).pow(n) - 1) / 9 * i).val() << endl;
}
return 0;
}
if (n <= 10) {
ll g = 0;
string s;
rep(i, 10) s.append(c[i], '0' + i);
do {
g = gcd(g, stoll(s));
} while(next_permutation(all(s)));
cout << g << endl;
return 0;
}
int r9 = 0;
rep(i, 10) r9 = (r9 + (ll)i * c[i]) % 9;
bool b1 = false, b2 = false, b3 = false;
rep(i, 10) {
if (i % 2) b1 = true;
if (i % 4) b2 = true;
if (i % 8) b3 = true;
}
int g = 1;
if (r9 == 0) g *= 9;
if (!b1) g *= 2;
if (!b2) g *= 2;
if (!b3) g *= 2;
cout << g << endl;
}
Kude