結果
問題 |
No.1339 循環小数
|
ユーザー |
|
提出日時 | 2021-08-07 15:53:50 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,028 bytes |
コンパイル時間 | 2,046 ms |
コンパイル使用メモリ | 199,168 KB |
最終ジャッジ日時 | 2025-01-23 16:42:51 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 20 TLE * 16 |
ソースコード
#include <bits/stdc++.h> using namespace std; map <int, int> res; int main(void) { cin.tie(0); ios::sync_with_stdio(false); int n, t; cin >> t; while (t--) { cin >> n; while (1) { if (n % 2 != 0) break; n /= 2; } while (1) { if (n % 5 != 0) break; n /= 5; } if (n == 1) { cout << 1 << '\n'; } else { if (res.find(n) == res.end()) { int val = 1; for (int i = 1; ; i++) { val *= 10; val %= n; if (val == 1) { res[n] = i; break; } } cout << res[n] << '\n'; } else { cout << res[n] << '\n'; } } } return 0; }