結果
| 問題 |
No.2452 Incline
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-12-08 21:51:13 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 168 ms / 2,000 ms |
| コード長 | 1,750 bytes |
| コンパイル時間 | 5,659 ms |
| コンパイル使用メモリ | 310,712 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-08 21:51:22 |
| 合計ジャッジ時間 | 8,064 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 8 |
ソースコード
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
namespace my{
using ml=atcoder::modint998244353;
auto&operator>>(istream&i,ml&x){int t;i>>t;x=t;return i;}
auto&operator<<(ostream&o,const ml&x){return o<<(int)x.val();}
#define LL(...) ll __VA_ARGS__;lin(__VA_ARGS__)
#define FO(n) for(ll ij=n;ij--;)
#define FOR(i,...) for(auto[i,i##stop,i##step]=range(0,__VA_ARGS__);i<i##stop;i+=i##step)
#define multiple_testcases void solve();}int main(){my::io();int T;std::cin>>T;while(T--)my::solve();}namespace my{
void io(){cin.tie(nullptr)->sync_with_stdio(0);cout<<fixed<<setprecision(15);}
using ll=long long;
using ull=unsigned long long;
using ulll=__uint128_t;
using lll=__int128_t;
istream&operator>>(istream&i,ulll&x){ull t;i>>t;x=t;return i;}
ostream&operator<<(ostream&o,const ulll&x){return(x<10?o:o<<x/10)<<ll(x%10);}
istream&operator>>(istream&i,lll&x){ll t;i>>t;x=t;return i;}
ostream&operator<<(ostream&o,const lll&x){return o<<string(x<0,'-')<<ulll(x>0?x:-x);}
constexpr auto range(bool s,auto...a){array<ll,3>r{0,0,1};ll I=0;((r[I++]=a),...);if(!s&&I==1)swap(r[0],r[1]);r[0]-=s;return r;}
constexpr char newline=10;
constexpr char space=32;
void lin(auto&...a){(cin>>...>>a);}
template<char c=space>void pp(const auto&...a){ll n=sizeof...(a);((cout<<a<<string(--n>0,c)),...);cout<<newline;}
template<class T=lll>T floor_sum(lll n,lll m,lll a,lll b){
if(a<0)return-floor_sum<T>(n,m,-a,-b+m-1);
if(b<0)return floor_sum<T>(n,m,a,b*(1-m))+(T)b*n;
if(a>=m||b>=m)return floor_sum<T>(n,m,a%m,b%m)+(T)(n-1)*n/2*(a/m)+(T)n*(b/m);
if(a==0)return 0;
return floor_sum<T>((a*n+b)/m,a,m,(a*n+b)%m);
}
multiple_testcases
void solve(){
LL(N,M,L,R);
pp(floor_sum<ml>(M+1,N-1,-1,R)-floor_sum<ml>(M+1,N-1,-1,L+N-2)+M+1);
}}