結果

問題 No.25 有限小数
ユーザー ふーらくたるふーらくたる
提出日時 2016-07-30 16:38:39
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 553 bytes
コンパイル時間 643 ms
コンパイル使用メモリ 63,860 KB
実行使用メモリ 196,352 KB
最終ジャッジ日時 2024-04-24 13:11:00
合計ジャッジ時間 7,416 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

typedef unsigned long long ull;

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

    while (N != 0) {
        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