結果

問題 No.1559 Next Rational
ユーザー 👑 Nachia
提出日時 2021-06-25 22:10:00
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 591 bytes
コンパイル時間 813 ms
コンパイル使用メモリ 76,408 KB
最終ジャッジ日時 2025-01-22 12:18:39
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 TLE * 1
other AC * 7 TLE * 8
権限があれば一括ダウンロードができます

ソースコード

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