結果
問題 |
No.443 GCD of Permutation
|
ユーザー |
![]() |
提出日時 | 2016-11-11 23:44:53 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 507 bytes |
コンパイル時間 | 963 ms |
コンパイル使用メモリ | 65,316 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-25 09:46:21 |
合計ジャッジ時間 | 4,308 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 12 RE * 16 |
ソースコード
#include<iostream> #include<algorithm> #include<string> #include<vector> using namespace std; typedef long long ll; ll gcd(ll a, ll b) { if (b == 0)return a; else return gcd(b, a%b); } int main() { string input; cin >> input; ll res = stoll(input); //vector<int> v; sort(input.begin(), input.end()); //for (int i = 0; i < input.size(); i++)v.push_back(input[i]-'0'); do { ll a = stoll(input); res = gcd(res, a); } while (next_permutation(input.begin(), input.end())); cout << res << endl; }