結果
| 問題 |
No.747 循環小数N桁目 Hard
|
| コンテスト | |
| ユーザー |
ats5515
|
| 提出日時 | 2018-10-19 21:38:53 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 824 bytes |
| コンパイル時間 | 650 ms |
| コンパイル使用メモリ | 81,492 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-18 20:13:57 |
| 合計ジャッジ時間 | 3,394 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 120 |
ソースコード
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
string N, K;
cin >> N >> K;
int res = 0;
int n = 0;
int a = 1;
for (int i = N.size() - 1; i >= 0; i--) {
n = (n + (a * (N[i] - '0'))) % 6;
a = (a * 10) % 6;
}
//cerr << "n=" << n << endl;
int k = (K.back() - '0') % 2;
if (n == 1 || n == 0 || n == 3 || n == 4) {
res = n;
}
else if (n == 2) {
if (k == 0) {
res = 4;
}
else {
res = 2;
}
}
else if (n == 5) {
if (k == 0) {
res = 1;
}
else {
res = 5;
}
}
//cerr << "res=" << res << endl;
cout << "428571"[res % 6] << endl;
}
ats5515