結果
問題 |
No.25 有限小数
|
ユーザー |
![]() |
提出日時 | 2019-04-08 19:27:53 |
言語 | C (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 533 bytes |
コンパイル時間 | 133 ms |
コンパイル使用メモリ | 29,184 KB |
実行使用メモリ | 36,124 KB |
最終ジャッジ日時 | 2024-07-01 22:54:45 |
合計ジャッジ時間 | 6,833 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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, N *= 10; ans = (int)(N / M); } } printf("%d\n", ans); return 0; }