結果

問題 No.2176 LRM Question 1
ユーザー pseudosodiumpseudosodium
提出日時 2023-01-06 21:34:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 1,807 bytes
コンパイル時間 3,268 ms
コンパイル使用メモリ 165,252 KB
実行使用メモリ 10,932 KB
最終ジャッジ日時 2023-08-20 14:36:51
合計ジャッジ時間 2,924 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 41 ms
10,832 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 36 ms
9,700 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 37 ms
10,932 KB
testcase_14 AC 42 ms
10,888 KB
testcase_15 AC 34 ms
9,348 KB
testcase_16 AC 27 ms
8,248 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 33 ms
9,964 KB
testcase_19 AC 23 ms
7,672 KB
testcase_20 AC 9 ms
4,616 KB
testcase_21 AC 19 ms
6,200 KB
testcase_22 AC 3 ms
4,376 KB
testcase_23 AC 16 ms
5,876 KB
testcase_24 AC 17 ms
6,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
// #include <ext/rope>
// using namespace __gnu_cxx;
using namespace std;

// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename T> istream& operator >> (istream& in, vector<T>& v) { for (auto &it:v) in >> it; return in; }
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (auto it:v) os << it << " "; return os; }
template <typename T1, typename T2> istream& operator >> (istream& in, pair<T1,T2>& p) { in >> p.first >> p.second; return in; }
template <typename T1, typename T2> ostream& operator << (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> void minn(T1& a, T2 b) { a = min(a,b); }
template <typename T1, typename T2> void maxx(T1& a, T2 b) { a = max(a,b); }

#define int long long
// #define double long double
#define pb push_back
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define sz(v) (int)v.size()
#define deb(x) cerr<<#x<<"="<<x<<'\n';

const int mod = 1e9 + 7;
const int mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795;
const int raw_mango_seed = chrono::steady_clock::now().time_since_epoch().count();
mt19937 rng(raw_mango_seed);

void solve() {
    int l,r,m; cin>>l>>r>>m;
    minn(r,m);
    vector<int> f(r+1);
    f[0]=1;
    int ans=0;
    for(int i=1;i<=r;i++){
        f[i]=(f[i-1]*i)%m;
    }
    for(int i=1;i<=r;i++){
        f[i]=(f[i-1]*f[i])%m;
        if(i>=l)ans=(ans+f[i])%m;
    }
    cout<<ans;
}

int32_t main() {
    cin.tie(0)->sync_with_stdio(0);
    int tc=1;
    // cin>>tc;
    while(tc--){
        solve();
    }
    return 0;
}


0