結果
問題 |
No.443 GCD of Permutation
|
ユーザー |
|
提出日時 | 2020-08-10 21:20:39 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 436 bytes |
コンパイル時間 | 4,896 ms |
コンパイル使用メモリ | 196,808 KB |
最終ジャッジ日時 | 2025-01-12 19:51:33 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 14 WA * 14 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; int main(){ string s; cin>>s; if(count(s.begin(),s.end(),s[0])==s.length()){ cout<<s<<'\n'; return 0; } sort(s.begin(),s.end()); int g=0; if(s.length()<9) g=stoi(s); s.erase(unique(s.begin(),s.end()),s.end()); rep(i,s.length()) rep(j,s.length()) { int a=s[i]-'0',b=s[j]-'0'; g=gcd(g,9*(a+b)); } cout<<g<<'\n'; return 0; }