結果

問題 No.2001 Distanced Triple
コンテスト
ユーザー eQe
提出日時 2025-11-25 16:18:13
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,257 bytes
コンパイル時間 2,846 ms
コンパイル使用メモリ 278,808 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-11-25 16:18:18
合計ジャッジ時間 4,282 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
#if __has_include(<atcoder/all>)
#include<atcoder/modint>
#endif
using namespace std;
#define done(...) return pp(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;lin(__VA_ARGS__)
#define defpp template<ostream&o=cout>void pp(const auto&...a){[[maybe_unused]]const char*c="";((o<<c<<a,c=" "),...);o<<'\n';}void epp(const auto&...a){pp<cerr>(a...);}
#define entry defpp void main();void main2();}int main(){my::io();my::main();}namespace my{
#define use_ml998244353 using ml=atcoder::modint998244353;
namespace my{
auto&operator<<(ostream&o,const atcoder::modint998244353&x){return o<<(int)x.val();}
void io(){cin.tie(nullptr)->sync_with_stdio(0);cout<<fixed<<setprecision(15);}
using ll=long long;
void lin(auto&...a){(cin>>...>>a);}
constexpr auto square(auto x){return x*x;}
constexpr auto cube(auto x){return x*x*x;}
bool amax(auto&a,const auto&b){return a<b?a=b,1:0;}
}
namespace my{entry
void main(){
  LL(S,T);
  LL(A,B,C);
  S=S+A+B;
  if(S>T)done(0);
  ll U=-A-B+C;
  if(U>T-S)done(0);
  amax(U,0);

  ll F=T-S;
  use_ml998244353
  ml ans=0;
  ans+=cube<ml>(F)/6;
  ans+=square<ml>(F);
  ans-=ml(F)*U*U/2;
  ans-=ml(F)*U/2;
  ans+=ml(F)*11/6;
  ans+=cube<ml>(U)/3;
  ans-=square<ml>(U)/2;
  ans-=ml(U)*5/6;
  ans+=1;
  pp(ans);
}}
0