結果

問題 No.443 GCD of Permutation
ユーザー vockyXvockyX
提出日時 2016-11-11 23:44:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 507 bytes
コンパイル時間 686 ms
コンパイル使用メモリ 73,216 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-04 03:19:25
合計ジャッジ時間 4,192 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0