結果

問題 No.3357 eの部分和 mod 素数
コンテスト
ユーザー yu23578
提出日時 2025-09-15 21:35:18
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2,392 ms / 10,000 ms
コード長 393 bytes
コンパイル時間 1,538 ms
コンパイル使用メモリ 196,924 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-11-14 20:59:35
合計ジャッジ時間 29,658 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using namespace atcoder;
using mint = modint;
#define int long long

int P;

signed main(){
  cin>>P;
  modint::set_mod(P);
  mint rui = 1;
  mint ans = 0;
  for(int i = 1; i <= P-1; i++){
    rui *= i;
  }
  rui = 1 / rui;
  for(int i = P-1; i >= 0; i--){
    ans += rui;
    rui *= i;
  }
  cout << ans.val() << "\n";
}
0