結果
| 問題 |
No.1339 循環小数
|
| コンテスト | |
| ユーザー |
どらら
|
| 提出日時 | 2021-01-15 23:16:03 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 754 bytes |
| コンパイル時間 | 1,595 ms |
| コンパイル使用メモリ | 173,468 KB |
| 実行使用メモリ | 119,328 KB |
| 最終ジャッジ日時 | 2024-11-26 17:27:16 |
| 合計ジャッジ時間 | 52,705 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 TLE * 16 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
int get_period(int n)
{
map<int, int> mymap;
map<int, int>::iterator it;
int rem = 1, i = 1;
while (true){
rem = (10*rem) % n;
it = mymap.find(rem);
if (it != mymap.end())
return (i - it->second);
mymap[rem] = i;
i++;
}
return -1;
}
void solve(){
int N;
cin >> N;
cout << get_period(N) << endl;
}
int main(){
int t;
cin >> t;
rep(i,t){
solve();
}
return 0;
}
どらら