結果

問題 No.2749 随伴関手入門
ユーザー Spica08
提出日時 2024-05-10 21:35:20
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 661 bytes
コンパイル時間 1,859 ms
コンパイル使用メモリ 194,112 KB
最終ジャッジ日時 2025-02-21 12:23:27
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Matrix = vector<vector<ll>>;
const int inf = 1000000000;
const ll INF = 1000000000000000000;
const ll mod = 998244353;
const ull mod_hash = (1UL << 61) - 1;
const vector<int> dx = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};

int main(){
  int N; cin>>N;
  if(N==1){
    cout<<1<<endl;
    return 0;
  }
  int a1 = 1, a2 = 1;
  int i = 2;
  while(true){
    i++;
    int a3 = a1 + a2;
    if(a3 % N == 0){
      cout << i << endl;
      break;
    }
    a1 = a2;
    a2 = a3;
    a1 %= N;
    a2 %= N;
  }
  return 0;
}
0