結果

問題 No.25 有限小数
ユーザー ふーらくたるふーらくたる
提出日時 2016-07-30 16:55:53
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 691 bytes
コンパイル時間 459 ms
コンパイル使用メモリ 61,208 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-24 13:11:10
合計ジャッジ時間 1,231 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <set>
#include <string>
using namespace std;

typedef unsigned long long ull;

int main() {
    ull N, M;
    int ans = 0, times = 0;
    set<ull> recorder;
    cin >> N >> M;

    while (N != 0) {
        times++;
        if (times > 200) {
            cout << -1 << endl;
            break;
        }
        /*
        if (recorder.find(N) != recorder.end()) {
            cout << -1 << endl;
            return 0;
        }
        recorder.insert(N);
        */
        string str = to_string(N / M);
        for (auto ch : str) {
            if (ch != '0') ans = ch - '0';
        }
        N = (N % M) * 10;
    }
    cout << ans << endl;
    return 0;
}
0