結果

問題 No.2176 LRM Question 1
ユーザー planesplanes
提出日時 2023-01-07 15:14:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 552 bytes
コンパイル時間 1,608 ms
コンパイル使用メモリ 169,424 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-05-08 11:24:15
合計ジャッジ時間 2,884 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 42 ms
10,972 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 21 ms
11,076 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 22 ms
11,136 KB
testcase_09 AC 20 ms
10,868 KB
testcase_10 AC 36 ms
9,812 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 42 ms
11,028 KB
testcase_15 AC 34 ms
9,472 KB
testcase_16 AC 27 ms
8,284 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 19 ms
6,528 KB
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 17 ms
6,016 KB
testcase_24 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h> 
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 #define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)


int main() {
  ll L,R,M;cin>>L>>R>>M;

if(M<=L) {
    cout<<0<<endl;
    return 0;
  }

  vector<ll> t(M+1,1);
  for(ll i=1;i<=M;i++) {
    t[i]=t[i-1]*i;
    t[i]%=M;
  }

  ll s=0;
  ll now=1;
  for(ll i=1;i<=L;i++) {
    now*=t[i];
    now%=M;
  }
  s+=now;
  s%=M;

  for(ll i=L+1;i<=min(R,M-1);i++) {
now*=t[i];
now%=M;
s+=now;
  s%=M;
  }

  cout<<s<<endl;
}

0