結果

問題 No.443 GCD of Permutation
ユーザー simezi_tansimezi_tan
提出日時 2016-12-03 13:09:16
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 844 bytes
コンパイル時間 1,730 ms
コンパイル使用メモリ 145,108 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-18 12:49:52
合計ジャッジ時間 3,359 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 WA -
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 WA -
testcase_23 AC 2 ms
4,380 KB
testcase_24 WA -
testcase_25 AC 2 ms
4,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,376 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;
	bool allsame = 1;
	int gcd = 0, sum = 0;
	
	for(char c : in){
		if(c != in[0]) allsame = 0;
		gcd = __gcd(gcd, c - '0');
	}
	if(allsame){
		cout << in << endl;
		return 0;
	}
	
	if(gcd > 1) for(char &c : in) c = (c - '0') / gcd + '0';
	for(char c : in) sum += c - '0';
	if(sum % 9 == 0) gcd *= 9;
	else if(sum % 3 == 0) gcd *= 3;
	cout << gcd << endl;
	
	return 0;
}
0