結果
問題 | No.443 GCD of Permutation |
ユーザー |
![]() |
提出日時 | 2016-11-11 23:10:37 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,156 bytes |
コンパイル時間 | 1,774 ms |
コンパイル使用メモリ | 161,676 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-25 10:41:39 |
合計ジャッジ時間 | 2,589 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 WA * 6 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef signed long long ll;#undef _P#define _P(...) (void)printf(__VA_ARGS__)#define FOR(x,to) for(x=0;x<(to);x++)#define FORR(x,arr) for(auto& x:arr)#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)#define ALL(a) (a.begin()),(a.end())#define ZERO(a) memset(a,0,sizeof(a))#define MINUS(a) memset(a,0xff,sizeof(a))//-------------------------------------------------------string S;int L;int num[10];int sum;void solve() {int i,j,k,l,r,x,y; string s;cin>>S;FORR(c,S) num[c-'0']++, sum+=c-'0';FOR(i,10) {if(num[i]==S.size()) {cout<<S<<endl;return;}}int ma=0;for(i=1;i<=9;i++) {int ok=1;FOR(j,10) if(j%i && num[j]) ok=0;if(ok==0) continue;if(sum%9==0) ma=max(ma,i*9/__gcd(i,9));if(sum%3==0) ma=max(ma,i*3/__gcd(i,3));ma=max(ma,i);}if(num[1]+num[8]==S.size() && num[1]==num[8]) ma*=7;cout<<ma<<endl;}int main(int argc,char** argv){string s;int i;if(argc==1) ios::sync_with_stdio(false), cin.tie(0);FOR(i,argc-1) s+=argv[i+1],s+='\n';FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);solve(); return 0;}