結果
問題 |
No.443 GCD of Permutation
|
ユーザー |
|
提出日時 | 2017-12-19 16:22:46 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 550 bytes |
コンパイル時間 | 1,368 ms |
コンパイル使用メモリ | 110,816 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-12 23:12:45 |
合計ジャッジ時間 | 2,254 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 28 |
コンパイルメッセージ
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/std/numeric.d(2999): Warning: cannot inline function `std.numeric.gcdImpl!uint.gcdImpl`
ソースコード
import std.algorithm, std.conv, std.range, std.stdio, std.string; import std.numeric; // gcd, fft import std.bigint; // BigInt void main() { auto n = readln.chomp; auto v = new bool[](10); foreach (c; n) v[c-'0'] = true; if (v.count(true) == 1) { writeln(n); return; } auto g = 0; foreach (i; 0..9) foreach (j; i+1..10) if (v[i] && v[j]) g = g ? gcd(g, 9*(j-i)) : 9*(j-i); auto m = BigInt(n); foreach_reverse (i; 1..g+1) if (g % i == 0 && m % i == 0) { writeln(i); return; } }