結果

問題 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,415 ms
コンパイル使用メモリ 166,148 KB
実行使用メモリ 10,816 KB
最終ジャッジ日時 2023-08-21 05:51:17
合計ジャッジ時間 3,304 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 41 ms
10,756 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 21 ms
10,804 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 20 ms
10,816 KB
testcase_09 AC 20 ms
10,676 KB
testcase_10 AC 34 ms
9,484 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 42 ms
10,724 KB
testcase_15 AC 33 ms
9,208 KB
testcase_16 AC 27 ms
8,252 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 18 ms
6,424 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 16 ms
5,660 KB
testcase_24 AC 2 ms
4,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