結果

問題 No.443 GCD of Permutation
ユーザー Kmcode1Kmcode1
提出日時 2016-11-11 22:29:29
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 425 bytes
コンパイル時間 1,588 ms
コンパイル使用メモリ 149,588 KB
実行使用メモリ 5,332 KB
最終ジャッジ日時 2023-08-16 18:55:22
合計ジャッジ時間 2,455 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

string s;

set<int> S;
int main(){
	cin >> s;
	for (int i = 0; i < s.size(); i++){
		S.insert(s[i] - '0');
	}
	if (S.size() == 1){
		cout << s << endl;
		return 0;
	}
	int gc = 0;
	for (auto it = S.begin(); it != S.end(); it++){
		for (auto itt = S.begin(); itt != S.end(); itt++){
			int sa = abs((*it) - (*itt));
			gc = __gcd(gc, sa);
		}
	}
	cout << gc << endl;
	return 0;
}
0