結果
| 問題 |
No.25 有限小数
|
| コンテスト | |
| ユーザー |
ふーらくたる
|
| 提出日時 | 2016-07-30 16:38:39 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 553 bytes |
| コンパイル時間 | 703 ms |
| コンパイル使用メモリ | 64,836 KB |
| 実行使用メモリ | 188,072 KB |
| 最終ジャッジ日時 | 2024-11-06 21:19:09 |
| 合計ジャッジ時間 | 7,463 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 TLE * 1 -- * 13 |
ソースコード
#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;
}
ふーらくたる