結果
問題 | No.2176 LRM Question 1 |
ユーザー |
![]() |
提出日時 | 2023-01-06 22:29:46 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 52 ms / 2,000 ms |
コード長 | 2,701 bytes |
コンパイル時間 | 1,024 ms |
コンパイル使用メモリ | 114,092 KB |
最終ジャッジ日時 | 2025-02-10 00:09:02 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <iostream>#include <vector>#include <map>#include <algorithm>#include <cmath>#include <iomanip>#include <string>#include <list>#include <cassert>#include <numeric>#include <cstdint>#include <queue>#include <deque>#include <stack>#include <set>#include <random>#include <bitset>#include <climits>// #include <atcoder/all>using ll = long long;using ld = long double;using namespace std;// using namespace atcoder;using P = pair<ll, ll>;using Graph = vector<vector<ll>>;using Priority = priority_queue<ll, vector<ll>, greater<ll>>;// 昇順using Priority_pair = priority_queue<P, vector<P>, greater<P>>;// using mint_17 = modint1000000007;// using mint = modint998244353;#define mod 1000000007#define MAX_WIDTH 60#define MAX_HEIGHT 60#define inf 1e9#define INF 8e18#define MOD 998244353#define PI 3.141592653589793#define rep(i, a, b) for(ll i=(a);i<(b);i++)#define rrep(i, a, b) for(ll i=(a);i>=(b);i--)#define fore(i, a) for(auto &i: a)#define all(v) (v).begin(), (v).end()#define rall(v) (v).rbegin(), (v).rend()#define YES(a) cout << ((a) ? "YES" : "NO") << endl#define Yes(a) cout << ((a) ? "Yes" : "No") << endl#define pb push_back#define fi first#define se second#define vi vector<int>#define vll vector<ll>#define vld vector<ld>#define vs vector<string>#define vc vector<char>#define vp vector<pair<ll, ll>>#define mll map<ll, ll>#define msl map<string, ll>#define COUT(n) cout << (n) << endl#define isInGrid(a, b, h, w) (0 <= (a) && (a) < (h) && 0 <= (b) && (b) < (w))#define countBit(n) __builtin_popcountll(n)template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }template<typename T> void uniq(T &vec){sort(all(vec)); vec.erase(unique(all(vec)), vec.end());}template <class T> bool overflow_if_add(T a, T b) { return (numeric_limits<T>::max() - a) < b; }template <class T> bool overflow_if_mul(T a, T b) { return (numeric_limits<T>::max() / a) < b; }int vy4[] = {0, 1, 0, -1}, vx4[] = {1, 0, -1, 0};int vy8[] = {0, 1, 1, 1, 0, -1, -1, -1}, vx8[] = {1, 1, 0, -1, -1, -1, 0, 1};struct edge {ll to, cost;};ll L, R, M;int main(){cin >> L >> R >> M;ll cnt = 1, sum = 1, now = 1;vll V;while(1) {V.pb(sum);if(now%M == 0) {break;}cnt++;now *= cnt;now %= M;sum *= now;sum %= M;}ll ans = 0;ll r = min(R, (ll)(V.size()));rep(i,L-1,r) {if(V[i] == 0) break;ans += V[i];ans %= M;}COUT(ans);return 0;}