結果

問題 No.747 循環小数N桁目 Hard
ユーザー le_panda_noir
提出日時 2020-06-13 20:50:54
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 539 bytes
コンパイル時間 584 ms
コンパイル使用メモリ 68,768 KB
最終ジャッジ日時 2025-01-11 03:59:42
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 120
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)

int main() {
  string N, K;
  ins(N, K);

  int r = 0;
  rep(i, N.size()) {
    r = r * 10 + N[i];
    r %= 6;
  }
  if (r == 2) {
    if ((K.back() - '0') % 2 == 0)
      cout << 7 << endl;
    else
      cout << 8 << endl;
  } else if (r == 5)
    cout << "21"[(K.back() - '0') % 2] << endl;
  else
    cout << "285714"[(5+r)%6] << endl;

  return 0;
}
0