結果

問題 No.1559 Next Rational
ユーザー 👑 NachiaNachia
提出日時 2021-06-25 22:10:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 588 bytes
コンパイル時間 644 ms
コンパイル使用メモリ 70,948 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-07 14:34:40
合計ジャッジ時間 1,517 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 10 ms
4,376 KB
testcase_06 AC 14 ms
4,376 KB
testcase_07 AC 5 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 4 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <atcoder/modint>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)


using mll = atcoder::static_modint<1000000007>;


ull N;
mll A,B,K;

int main(){
  cin >> N;
  if(N >= 100000000) exit(0);
  { int a,b,k; cin >> a >> b >> k; A=a; B=b; K=k; }
  for(ull i=1; i<N; i++){
    mll C = (B * B + K) / A;
    A = B; B = C;
  }
  cout << A.val() << "\n";
  return 0;
}

struct ios_do_not_sync{
  ios_do_not_sync(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
  }
} ios_do_not_sync_inst;
0