結果
| 問題 | No.443 GCD of Permutation |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-05-19 20:25:38 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 828 bytes |
| 記録 | |
| コンパイル時間 | 851 ms |
| コンパイル使用メモリ | 106,204 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2026-03-17 10:41:44 |
| 合計ジャッジ時間 | 1,856 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 24 WA * 4 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:22:47: warning: 'void std::random_shuffle(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<char*, __cxx11::basic_string<char> >]' is deprecated: use 'std::shuffle' instead [-Wdeprecated-declarations]
22 | random_shuffle(s.begin(), s.end());
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/algorithm:63,
from main.cpp:4:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algo.h:4537:5: note: declared here
4537 | random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
| ^~~~~~~~~~~~~~
ソースコード
#include <random>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int p[] = { 2, 3, 5, 7 };
string s;
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
cin >> s;
bool same = true;
for (int i = 1; i < s.size(); i++) {
if (i >= 1 && s[i] != s[i - 1]) same = false;
}
if (same) cout << s << '\n';
else {
int ret = 1;
for (int i = 0; i < 4; i++) {
int z = 1 << 30;
for (int j = 0; j < 20; j++) {
random_shuffle(s.begin(), s.end());
int mod = p[i] * p[i] * p[i] * p[i] * p[i] * p[i], cur = 0;
for (int k = 0; k < s.size(); k++) {
cur = (cur * 10 + (s[k] - '0')) % mod;
}
int c = 0;
while (c < 6 && cur % p[i] == 0) cur /= p[i], c++;
z = min(z, c);
}
for (int j = 0; j < z; j++) ret *= p[i];
}
cout << ret << '\n';
}
return 0;
}