結果
| 問題 |
No.25 有限小数
|
| コンテスト | |
| ユーザー |
bal4u
|
| 提出日時 | 2019-04-08 19:07:50 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 525 bytes |
| コンパイル時間 | 160 ms |
| コンパイル使用メモリ | 29,056 KB |
| 実行使用メモリ | 6,912 KB |
| 最終ジャッジ日時 | 2024-07-01 22:53:49 |
| 合計ジャッジ時間 | 7,188 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / 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 {
while (N % M) N -= (N / M) * M, N *= 10;
ans = (int)(N / M);
}
}
printf("%d\n", ans);
return 0;
}
bal4u