結果
問題 | No.747 循環小数N桁目 Hard |
ユーザー |
|
提出日時 | 2020-08-01 23:50:50 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 17 ms / 2,000 ms |
コード長 | 600 bytes |
コンパイル時間 | 632 ms |
コンパイル使用メモリ | 67,456 KB |
最終ジャッジ日時 | 2025-01-12 13:00:32 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 120 |
ソースコード
#include <iostream> #include <string> void solve() { int n, k; { std::string ns; std::cin >> ns; n = 0; for (char c : ns) { n = (n * 10 + (c - '0')) % 6; } std::string ks; std::cin >> ks; k = 0; for (char c : ks) { k = (k * 10 + (c - '0')) % 6; } if (k == 0) k = 6; } int ans = 1; while (k--) (ans *= n) %= 6; std::cout << "428571"[ans] << "\n"; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }