結果
| 問題 |
No.2176 LRM Question 1
|
| コンテスト | |
| ユーザー |
coder_So_hey
|
| 提出日時 | 2023-01-06 22:48:10 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 944 bytes |
| コンパイル時間 | 413 ms |
| コンパイル使用メモリ | 55,792 KB |
| 実行使用メモリ | 13,644 KB |
| 最終ジャッジ日時 | 2024-11-30 19:18:14 |
| 合計ジャッジ時間 | 25,694 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 WA * 1 TLE * 8 |
ソースコード
#include <iostream>
using namespace std;
long long int fac(long long int n, long long int m){
if (n > 1) {
n *= fac(n - 1, m);
if (n >= m) {
n %= m;
}
return n;
} else {
return 1;
}
}
int main(){
long long int L, R, M;
cin >> L >> R >> M;
if (L >= M) {
cout << 0 << endl;
return 0;
}
long long int facto = 1, index = 2;
while (facto != 0) {
facto *= fac(index, M);
if (facto >= M) {
facto %= M;
}
index++;
}
long long int ans = 0;
for (long long int i = L; i < index + 1; i++) {
long long int a = 1;
for (long long int j = 1; j <= i; j++) {
a *= fac(j, M);
if (a >= M) {
a %= M;
}
}
ans += a;
if (ans >= M) {
ans %= M;
}
}
cout << ans << endl;
return 0;
}
coder_So_hey