結果
| 問題 |
No.443 GCD of Permutation
|
| コンテスト | |
| ユーザー |
vockyX
|
| 提出日時 | 2016-11-11 23:44:48 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 507 bytes |
| コンパイル時間 | 705 ms |
| コンパイル使用メモリ | 73,928 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-25 09:46:39 |
| 合計ジャッジ時間 | 3,719 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / 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;
}
vockyX