結果
問題 |
No.443 GCD of Permutation
|
ユーザー |
![]() |
提出日時 | 2018-05-31 01:06:47 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 778 bytes |
コンパイル時間 | 1,524 ms |
コンパイル使用メモリ | 166,700 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-30 08:28:39 |
合計ジャッジ時間 | 2,390 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 WA * 8 |
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 8 | main(){ | ^~~~
ソースコード
#include<bits/stdc++.h> #define rep(i, n) for(int i = 0; i < (int)(n); i++) using namespace std; typedef long long ll; int INF = (1LL << 30) - 1; int MOD = 1e9+7; main(){ string S; cin >> S; ll sum = 0; int cnt[10] = {}; for(auto c:S){ sum += c - '0'; cnt[c - '0']++; } int bit = 0; rep(i,9){ bit += ((bool)cnt[i+1]) << i; } if(__builtin_popcount(bit) == 1 && !cnt[0]){ cout << S << endl; return 0; } int ans = 1; if(sum % 9 == 0)ans *= 9; else if(sum % 3 == 0)ans *= 3; if(bit == 0b000010000) ans *= 5; if(!(bit & 0b101111111))ans *= 8; else if(!(bit & 0b101110111))ans *= 4; else if(!(bit & 0b101010101))ans *= 2; cout << ans << endl; }