結果
| 問題 |
No.443 GCD of Permutation
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-01-31 16:42:37 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 606 bytes |
| コンパイル時間 | 1,011 ms |
| コンパイル使用メモリ | 63,488 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2025-01-31 16:42:40 |
| 合計ジャッジ時間 | 2,728 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 22 WA * 6 |
ソースコード
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e4+10; char s[N]; bool book[20];
int main() {
//freopen("gcd.in","r",stdin);
//freopen("gcd.out","w",stdout);
ios::sync_with_stdio(false),cin.tie(nullptr);
int n,k=0; cin>>(s+1),n=strlen(s+1);
for(int i=1;i<=n;i++) book[s[i]-'0']=true;
for(int i=1;i<9;i++) for(int j=0;j<i;j++) if(book[i]&&book[j]) k=__gcd(k,9*(i-j));
if(!k) return cout<<(s+1),0;
for(int i=k;i>=1;i--) {
if(k%i) continue;
int r=0;
for(int j=1;j<=n;j++) r=(r*10+s[j]-'0')%i;
if(!r) return cout<<i,0;
}
return 0;
}
vjudge1