結果
問題 | No.2176 LRM Question 1 |
ユーザー |
|
提出日時 | 2023-01-06 22:45:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 43 ms / 2,000 ms |
コード長 | 3,295 bytes |
コンパイル時間 | 1,701 ms |
コンパイル使用メモリ | 168,704 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-30 19:12:48 |
合計ジャッジ時間 | 2,519 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h>using namespace std;// #include <atcoder/all>// using namespace atcoder;using ll = long long;const ll MOD = 998'244'353;//const ll MOD = 1000'000'007;const ll INF = (1LL<<30)-1;const ll LINF = (1LL<<62)-1;//#define _GLIBCXX_DEQUE_BUF_SIZE 512// int:[-2'147'483'648 : 2'147'483'647]// ll:[-9'223'372'036'854'775'808 : 9'223'372'036'854'775'807]#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)#define repi(i, a, n) for (ll i = a; i < (ll)(n); i++)#define pb(a) push_back(a)#define PS(a) cout<<(a)<<" ";#define PL(a) cout<<(a)<<endl;#define endl "\n"//#define ONLINE_JUDGE 1#ifdef ONLINE_JUDGE#define ES(a) while(0){}#define EL(a) while(0){}#else#define NAME(a) #a#define ES(a) cerr<<NAME(a)<<": "<<(a)<<" ";#define EL(a) cerr<<NAME(a)<<": "<<(a)<<endl;#endif#define END(a) {PL(a) return;}#define RES(a) cerr<<"\r"<<NAME(a)<<": "<<(a)<<" ";#define fi first#define se second#define ALL(a) (a).begin(),(a).end()#define RALL(a) (a).rbegin(),(a).rend()#define SORT(a) sort(a.begin(), a.end());#define REVERSE(a) reverse(a.begin(), a.end());#define ERASE(a) a.erase(unique(a.begin(), a.end()), a.end());using Pii = pair<int, int>;using Pll = pair<ll,ll>;template <class T> using V = vector<T>;template<typename T >ostream &operator<<(ostream &os, const vector< T > &v) {for(int i = 0; i < (int) v.size(); i++) {os << v[i] << (i + 1 != (int) v.size() ? " " : "");}return os;}template<typename T >istream &operator>>(istream &is, vector< T > &v) {for(T &in : v) is >> in;return is;}template<typename T, typename U > ostream &operator<<(ostream &os, const pair<T,U> &p) {os << p.first << ' ' << p.second; return os;}template<typename T, typename U > istream &operator>>(istream &is, pair<T,U> &p) { is >> p.first >> p.second; return is;}template<typename T, unsigned long int sz > ostream &operator<<(ostream &os, const array< T , sz > &v) {for(int i = 0; i < sz; i++) {os << v[i] << (i+ 1 != (int) v.size() ? " " : "");}return os;}template<typename T, unsigned long int sz > istream &operator>>(istream &is, array< T , sz > &v) {for(T& in:v){cin>>in;} return is;}template<class T, class U > void chmin(T& t, const U& u) {if (t > u) t = u;}template<class T, class U > void chmax(T& t, const U& u) {if (t < u) t = u;}#if __has_include(<atcoder/modint>)#include <atcoder/modint>using namespace atcoder;// ostream &operator<<(ostream &os, const mint x) {os<<x.val();return os;}// istream &operator>>(istream &is, mint& x){ll val; is >> val; x = val; return is;}#endifvoid solve() {ll L,R,M; cin>>L>>R>>M;auto f = [&](ll x)->ll {EL(x)ll res = 0;ll g = 1;ll fact = 1;for(ll i=1;i<=x;i++){g *= fact;g %= M;fact *= i;fact %= M;res += g*fact;res %= M;ES(res) ES(g) EL(fact)if(g*fact%M==0) break;}return res;};ll ans = f(R)-f(L-1);ans += M*10;ans %= M;PL(ans)return;}int main() {std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);std::cout << std::fixed << std::setprecision(15);int TT = 1;//cin>>TT;for(int tt = 0; tt<TT; tt++) solve();return 0;}