結果

問題 No.443 GCD of Permutation
ユーザー simezi_tansimezi_tan
提出日時 2016-12-03 15:22:38
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 990 bytes
コンパイル時間 1,407 ms
コンパイル使用メモリ 153,292 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-18 12:50:23
合計ジャッジ時間 3,100 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

string in;

int main(){
	cin >> in;
	
	int ans = 0;
	vi v;
	bool allsame = 1;
	set<int> s, t;
	
	for(char c : in){
		if(c != in[0]) allsame = 0;
		s.insert(c - '0');
	}
	if(allsame){
		cout << in << endl;
		return 0;
	}
	for(int a : s) for(int b : s) if(a > b) v.pb(9 * (a - b));
	for(int x : v) for(int y = x, i = 1; i * i <= y; i++) if(y % i == 0){
		t.insert(i);
		t.insert(y / i);
	}
	for(int x : t){
		int d = 0;
		for(char c : in){
			d *= 10; d += c - '0'; d %= x;
		}
		if(d == 0) ans = max(ans, x);
	}
	
	cout << ans << endl;
	
	return 0;
}
0