結果
| 問題 |
No.747 循環小数N桁目 Hard
|
| コンテスト | |
| ユーザー |
square1001
|
| 提出日時 | 2018-10-19 21:28:23 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 563 bytes |
| コンパイル時間 | 548 ms |
| コンパイル使用メモリ | 66,764 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-18 19:58:08 |
| 合計ジャッジ時間 | 3,254 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 3 |
| other | AC * 10 WA * 110 |
ソースコード
#include <string>
#include <iostream>
using namespace std;
int modsix(string s) {
bool modtwo = false;
if ((s.back() - 48) % 2 == 0) modtwo = true;
int modthree = 0;
for (int i = 0; i < s.size(); ++i) {
modthree = (modthree + (s[i] - 48)) % 3;
}
if (modthree % 2 == 1) modthree += 3;
return modthree;
}
int main() {
int a[] = { 1, 4, 2, 8, 5, 7 };
string s, t;
cin >> s >> t;
int as = modsix(s);
int at = modsix(t);
int val = 1;
for (int i = 0; i < at; ++i) {
val *= as;
val %= 6;
}
val = (val + 5) % 6;
cout << a[val] << endl;
return 0;
}
square1001