結果
問題 |
No.443 GCD of Permutation
|
ユーザー |
![]() |
提出日時 | 2016-12-03 13:09:16 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 844 bytes |
コンパイル時間 | 1,389 ms |
コンパイル使用メモリ | 159,456 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-27 17:56:39 |
合計ジャッジ時間 | 2,739 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 23 WA * 5 |
ソースコード
#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; }