結果

問題 No.25 有限小数
ユーザー hogeover30hogeover30
提出日時 2015-02-25 17:32:55
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 484 bytes
コンパイル時間 447 ms
コンパイル使用メモリ 59,328 KB
実行使用メモリ 7,444 KB
最終ジャッジ日時 2023-09-06 04:37:37
合計ジャッジ時間 7,676 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    long long n, m;
    while (cin>>n>>m) {
        auto g=__gcd(n, m);
        n/=g, m/=g;

        int c2=0, c5=0;
        while (m%2==0) { m/=2; ++c2; }
        while (m%5==0) { m/=5; ++c5; }

        if (m>1)
            cout<<-1<<endl;
        else {
            while (c5--) n=n*2%10;
            while (c2--) n=n*5%10;
            while (n%10==0) n/=10;
            cout<<n%10<<endl;
        }
    }
}
0