結果

問題 No.1559 Next Rational
ユーザー 👑 NachiaNachia
提出日時 2021-06-25 22:10:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 591 bytes
コンパイル時間 686 ms
コンパイル使用メモリ 80,816 KB
実行使用メモリ 11,960 KB
最終ジャッジ日時 2023-09-07 14:34:38
合計ジャッジ時間 7,216 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#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;
  { 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