結果
| 問題 |
No.2176 LRM Question 1
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-01-06 21:28:26 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 861 bytes |
| コンパイル時間 | 2,403 ms |
| コンパイル使用メモリ | 209,880 KB |
| 最終ジャッジ日時 | 2025-02-09 23:38:48 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 WA * 8 TLE * 1 |
ソースコード
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod_pow(ll a,ll b,ll mod){
a%=mod;
if(b==0)return 1;
if(b==1)return a;
ll res=mod_pow(a,b/2,mod)%mod;
res*=res; res%=mod;
if(b%2)res*=a;
return res%mod;
}
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
ll L,R,M; cin >> L >> R >> M;
ll res = 0;
ll cur = 1;
ll u = 1;
for (int i = 1; i < L-1; ++i) {
u *= i;
u %= M;
}
for (ll i = L; i <= R; ++i) {
if(i >= M) break;
u *= i; u %= M;
if(i == L){
for (int j = 1; j <= L; ++j) {
cur *= mod_pow(j,L+1-j,M);
cur %= M;
}
}
else{
cur *= u; cur %= M;
}
res += cur;
}
cout << res%M << endl;
}