結果
問題 |
No.747 循環小数N桁目 Hard
|
ユーザー |
|
提出日時 | 2018-11-04 13:36:57 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,181 bytes |
コンパイル時間 | 1,469 ms |
コンパイル使用メモリ | 162,860 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-20 19:49:20 |
合計ジャッジ時間 | 4,468 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 105 WA * 15 |
ソースコード
#include <bits/stdc++.h> #include <unordered_set> using namespace std; #define ll long long #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) int digit(char c) { return static_cast<int>(c-'0'); } int digitsum(string s) { int sum=0; for(auto& ch : s)sum+=digit(ch); return sum; } int main() { cin.tie(0); ios::sync_with_stdio(false); cout<<setprecision(std::numeric_limits<float>::max_digits10); string n,k; cin>>n>>k; string temp = "x285714"; // cout << digitsum(n) << " " << digit(k[0]) << endl; if(digit(n.back())%2==0) { // 0 mod 2 if(digitsum(n)%3==0) { cout << temp[0] << endl; } if(digitsum(n)%3==1) { cout << temp[4] << endl; } if(digitsum(n)%3==2&&digit(k.back())%2==1) { cout << temp[2] << endl; } if(digitsum(n)%3==2&&digit(k.back())%2==0) cout << temp[4] << endl; } else { // 1 mod 2 if(digitsum(n)%3==0) { cout << temp[3] << endl; } if(digitsum(n)%3==1) { cout << temp[1] << endl; } if(digitsum(n)%3==2&&digit(k.back())%2==1) { cout << temp[5] << endl; } if(digitsum(n)%3==2&&digit(k.back())%2==0) cout << temp[1] << endl; } return 0; }