結果
問題 |
No.443 GCD of Permutation
|
ユーザー |
![]() |
提出日時 | 2016-11-11 23:41:18 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 748 bytes |
コンパイル時間 | 598 ms |
コンパイル使用メモリ | 73,360 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-25 09:45:57 |
合計ジャッジ時間 | 1,561 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 10 WA * 18 |
ソースコード
#include<iostream> #include<algorithm> #include<cstdio> #include<cstdlib> #include<vector> #include<map> #include<queue> #include<string> #include<sstream> #include<cmath> #include<numeric> using namespace std; int main(){ string n; cin >> n; int tmp = 0; int a = n[0]; bool f = true; for(int i=0; i<n.size(); i++){ tmp += n[i]; if( i == n.size()-1 ) continue; if( a != n[i] ) f = false; } if( f ){ cout << n << endl; return 0; } int ans = 1; if( tmp % 3 == 0 ) ans = 3; if( tmp % 9 == 0 ){ ans = 9; int p = (n[n.size()-1]-'0') + 10*(n[n.size()-2]-'0'); if( p%4 == 0 && p != 0 ) ans *= 4; else if( n[n.size()-1]%2 == 0 && p != 0 ) ans *= 2; } cout << ans << endl; return 0; }