結果
| 問題 |
No.747 循環小数N桁目 Hard
|
| コンテスト | |
| ユーザー |
xuelei
|
| 提出日時 | 2018-10-19 22:01:37 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 951 bytes |
| コンパイル時間 | 1,408 ms |
| コンパイル使用メモリ | 159,584 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-18 20:35:56 |
| 合計ジャッジ時間 | 3,948 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 120 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main() {
string num = "285714";
string n;
cin >> n;
int sum = 0, last = n[n.size() - 1];
for (int i = 0; i < n.size(); i++) {
sum += n[i] - '0';
}
int cnt = 0;
while (sum % 3 != 0 || last % 2 != 0) {
sum++;
last++;
cnt++;
}
if (cnt != 0) cnt = 6 - cnt;
if (cnt == 0) {
cout << num[5] << endl;
return 0;
}
if (cnt == 1) {
cout << num[0] << endl;
return 0;
}
string k;
cin >> k;
if (cnt == 2) {
if ((k[k.size() - 1] - '0') % 2 == 0) {
cout << num[3] << endl;
} else {
cout << num[1] << endl;
}
return 0;
}
if (cnt == 3) {
cout << num[2] << endl;
return 0;
}
if (cnt == 4) {
cout << num[3] << endl;
return 0;
}
if (cnt == 5) {
if ((k[k.size() - 1] - '0') % 2 == 0) {
cout << num[0] << endl;
} else {
cout << num[4] << endl;
}
return 0;
}
return 0;
}
xuelei