Codeforces 1485C Floor and Mod (枚举)

网友投稿 562 2022-11-17

Codeforces 1485C Floor and Mod (枚举)

Codeforces 1485C Floor and Mod (枚举)

​​原题链接​​

接下来只需枚举k,看有多少对符合的数即可。

#includeusing namespace std;typedef long long ll;typedef unsigned long long ull;typedef pairPLL;typedef pairPII;typedef pairPDD;#defineinline ll read(){ll x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;}ll ksm(ll a,ll b,ll p){ll res=1;while(b){if(b&1)res=res*a%p;a=a*a%p;b>>=1;}return res;}const int maxn=1e6+7;void solve(){ ll x=read(),y=read(); ll res=0; for(ll k=1;k*k<=x;k++) res=res+max(0ll,min(y,x/k-1)-k); printf("%lld\n",res);}int main(){ int T=read(); while(T--) solve(); return 0;}

参考:官方题解

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:STL 与 线程安全
下一篇:AcWing288. 休息时间(环形DP)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~