結果

問題 No.2891 Mint
ユーザー HIcoder
提出日時 2024-09-30 21:13:00
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 2,737 bytes
コンパイル時間 1,481 ms
コンパイル使用メモリ 115,364 KB
最終ジャッジ日時 2025-02-24 14:20:14
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 40
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:106:17: warning: ‘l’ may be used uninitialized [-Wmaybe-uninitialized]
  106 |     for(ll c=1;c<=l;c++){
      |                ~^~~
main.cpp:88:8: note: ‘l’ was declared here
   88 |     ll l;
      |        ^

ソースコード

diff #
プレゼンテーションモードにする

#include<iostream>
#include<string>
#include<queue>
#include<vector>
#include<cassert>
#include<random>
#include<set>
#include<map>
#include<cassert>
#include<unordered_map>
#include<bitset>
#include<numeric>
#include<algorithm>
using namespace std;
typedef long long ll;
const int inf=1<<30;
const ll INF=1LL<<62;
typedef pair<int,int> P;
typedef pair<int,P> PP;
const ll MOD=998244353;
const int mod = 998244353;
struct mint {
long long x; // typedef long long long long;
mint(long long x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
mint operator+(const mint a) const { return mint(*this) += a;}//constx
mint operator-(const mint a) const { return mint(*this) -= a;}
mint operator*(const mint a) const { return mint(*this) *= a;}
bool operator==(const mint a) const {return a.x==x;}
mint pow(unsigned long long int t) const {
assert(t>=0);
if (!t) return 1;
//at t%=(mod-1)
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
// for prime mod
mint inv() const { return pow(mod-2);}
mint& operator/=(const mint a) { return *this *= a.inv();}
mint operator/(const mint a) const { return mint(*this) /= a;}
};
std::istream& operator>>(std::istream& is, mint& a) { return is >> a.x;}
std::ostream& operator<<(std::ostream& os, const mint& a) { return os << a.x;}
struct combination {
std::vector<mint> fact, ifact;
combination(int n):fact(n+1),ifact(n+1) {
assert(n < mod);
fact[0] = 1;
for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
}
mint operator()(int n, int K) {
if (K < 0 || K > n) return 0;
return fact[n]*ifact[K]*ifact[n-K];
}
};
int main(){
ll N,M;
cin>>N>>M;
if(M==1){
cout<<N-1<<endl;
return 0;
}
mint sum=0;
ll l;
ll sqrtM=sqrt(M);
for(ll d=1;d<=sqrtM;d++){
ll r=min(N,M/d);
l=M/(d+1);
//k=(l,r]M-k*d.d
if(r==0) break;
if(l>r) continue;
mint add1=mint( (M-(l+1)*d) + (M-r*d) )*(r-l)/2;
//cout<<"d="<<d<<",l="<<l<<",r="<<r<<",add1="<<add1<<endl;
sum+=add1;
}
mint add2=0;
for(ll c=1;c<=l;c++){
add2+=M%c;
}
sum+=add2;
cout<<sum<<endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0