結果
問題 | No.25 有限小数 |
ユーザー |
![]() |
提出日時 | 2019-04-08 20:06:36 |
言語 | C (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 565 bytes |
コンパイル時間 | 203 ms |
コンパイル使用メモリ | 29,696 KB |
実行使用メモリ | 8,608 KB |
最終ジャッジ日時 | 2024-07-01 22:54:12 |
合計ジャッジ時間 | 6,981 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 TLE * 1 -- * 13 |
ソースコード
// yukicoder: No.25 有限小数 // 2019.4.8 bal4u // 有限小数の条件と求め方 #include <stdio.h> int check(long long x) { while ((x & 1) == 0) x >>= 1; while (x % 5 == 0) x /= 5; return x == 1; } int main() { int ans; long long N, M; scanf("%lld%lld", &N, &M); if (!check(M)) ans = -1; else { if ((ans = (int)(N % M)) == 0) { N /= M; while ((ans = (int)(N % 10)) == 0) N /= 10; } else { N %= M; while (N % M) { N -= (N / M) * M; while (N < M) N *= 10; } ans = (int)(N / M); } } printf("%d\n", ans); return 0; }