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