对一个向下整除的式子快速求和
#include <bits/stdc++.h> using namespace std; typedef long long ll; //typedef __int128 LL; //typedef unsigned long long ull; //#define F first //#define S second typedef long double ld; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<ld,ld> pdd; const ld PI=acos(-1); const ld eps=1e-9; //unordered_map<int,int>mp; #define ls (o<<1) #define rs (o<<1|1) #define pb push_back //#define a(i,j) a[(i)*(m+2)+(j)] //m是矩阵的列数 //pop_back() const int seed=131; const int M = 1e5+7; const ll mod=998244353; /* int head[M],cnt; void init(){cnt=0,memset(head,0,sizeof(head));} struct EDGE{int to,nxt,val;}ee[M*2]; void add(int x,int y,int z){ee[++cnt].nxt=head[x],ee[cnt].to=y,ee[cnt].val=z,head[x]=cnt;} *//* ll cal(ll x)//x个点的满边图 { return ; }*/ ll qpow(ll a,ll b) { ll ans=1; while(b) { if(b&1)ans=ans*a%mod; a=a*a%mod; b=b/2; } return ans%mod; } int main() { int t; cin>>t; while(t--) { ll n,l,r; scanf("%lld%lld%lld",&n,&l,&r); ll ans=0; for(ll i=l,gx;i<=r;i=gx+1) { gx=(n/i)?min(n/(n/i),r):r; ll x=n/gx; ll tp=((i*(((((1+x)*x%mod)*(n-x))%mod-((x*(x+1)%mod)*(n-x-1))%mod+mod)%mod)%mod+n*( ((x+1)*(n-x-1)%mod +mod-x*(n-x)%mod)%mod )%mod + gx*( ((((1+x)*x%mod)*(n-x)%mod)+mod-(x*(x+1)%mod)*(n-x-1+2ll*mod)%mod )%mod )%mod+n*( ( (x+1)*(n-x-1+2ll*mod)%mod-x*(n-x)%mod +mod )%mod )%mod )*(gx-i+1)%mod)*qpow(2,mod-2)%mod; ans=(tp*qpow(2,mod-2)+ans)%mod; } printf("%lld ",ans); } return 0; }