結果
問題 | No.747 循環小数N桁目 Hard |
ユーザー |
![]() |
提出日時 | 2023-04-10 15:51:11 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 23 ms / 2,000 ms |
コード長 | 954 bytes |
コンパイル時間 | 4,129 ms |
コンパイル使用メモリ | 251,228 KB |
最終ジャッジ日時 | 2025-02-12 04:42:39 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 120 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; using ll=long long; using ld=long double; ld pie=3.141592653589793; ll inf=144494; ll mod=1000000007; int main(){ string n,k; cin >> n >> k; ll x=0; ll ten=1; reverse(n.begin(),n.end()); for (ll i = 0; i < n.size(); i++) { x+=(n[i]-'0')*ten; ten*=10; ten%=6; x%=6; } if (x==0) { cout << 4 << endl; }else if (x==1) { cout << 2 << endl; }else if (x==2) { if ((k[k.size()-1]-'0')%2) { cout << 8 << endl; }else{ cout << 7 << endl; } }else if (x==3) { cout << 5 << endl; }else if (x==4) { cout << 7 << endl; }else if (x==5) { if ((k[k.size()-1]-'0')%2) { cout << 1 << endl; }else{ cout << 2 << endl; } } }