結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    if(N == 1){
        cout << 1 << '\n';
        return 0;
    }
    int a = 1 % N, b = 1 % N;
    for(int i = 3; i <= N * N; i++){
        int c = (a + b) % N;
        if(c == 0){
            cout << i << '\n';
            return 0;
        }
        a = b, b = c;
    }
}
0