結果
| 問題 |
No.443 GCD of Permutation
|
| コンテスト | |
| ユーザー |
Bantako
|
| 提出日時 | 2018-05-31 01:06:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 767 bytes |
| コンパイル時間 | 1,585 ms |
| コンパイル使用メモリ | 167,672 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-30 08:28:33 |
| 合計ジャッジ時間 | 2,688 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 16 WA * 12 |
コンパイルメッセージ
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){
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;
}
Bantako