結果
問題 |
No.443 GCD of Permutation
|
ユーザー |
|
提出日時 | 2020-03-04 11:40:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 594 bytes |
コンパイル時間 | 650 ms |
コンパイル使用メモリ | 64,896 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 23:37:29 |
合計ジャッジ時間 | 1,533 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 25 WA * 3 |
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 5 | main() | ^~~~
ソースコード
#include<iostream> using namespace std; string s; int cnt[10]; main() { cin>>s; int N=s.size(); for(int i=0;i<N;i++)cnt[s[i]-'0']++; bool all=false; for(int i=0;i<10;i++)all=all||cnt[i]==N; if(all) { cout<<s<<endl; return 0; } int sum=0; for(int i=0;i<10;i++)sum+=cnt[i]*i; int ans=1; if(sum%9==0)ans=9; else if(sum%3==0)ans=3; if(cnt[0]+cnt[8]==N)ans*=8; else if(cnt[0]+cnt[4]+cnt[8]==N)ans*=4; else if(cnt[0]+cnt[2]+cnt[4]+cnt[6]+cnt[8]==N)ans*=2; if(cnt[0]+cnt[5]==N)ans*=5; if((cnt[0]+cnt[7]==N||cnt[1]+cnt[8]==N||cnt[2]+cnt[9]==N)&&N%3==0)ans*=7; cout<<ans<<endl; }