結果
問題 | No.747 循環小数N桁目 Hard |
ユーザー |
|
提出日時 | 2020-11-30 19:12:31 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 621 bytes |
コンパイル時間 | 883 ms |
コンパイル使用メモリ | 93,980 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-13 02:29:23 |
合計ジャッジ時間 | 4,924 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 120 |
ソースコード
#include <iostream> #include <string> #include <algorithm> #include <vector> #include <iomanip> #include <cmath> #include <stdio.h> #include <queue> #include <deque> #include <cstdio> #include <set> #include <map> #include <bitset> #include <stack> #include <cctype> using namespace std; string ans = ".285714"; int d[8] = { 0,1,4,3,4,1,6 }; int main() { string n, k; cin >> n >> k; int n1 = 0; for (int i = 0; i < n.size(); i++) { n1 *= 10; n1 += int(n[i] - '0'); n1 %= 6; } if (n1 == 0) { n1 = 6; } if (k[k.size() - 1] % 2 == 0) { cout << ans[d[n1]] << endl; } else { cout << ans[n1] << endl; } }