結果
問題 | No.2882 Comeback |
ユーザー |
|
提出日時 | 2024-09-08 13:54:34 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 231 ms / 2,000 ms |
コード長 | 806 bytes |
コンパイル時間 | 2,307 ms |
コンパイル使用メモリ | 200,224 KB |
最終ジャッジ日時 | 2025-02-24 05:37:02 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 30 |
ソースコード
#include<bits/stdc++.h>using namespace std;using ll=long long;void solve(){ll A,B;cin>>A>>B;set<ll> S;S.insert(A+1);S.insert(B+1);ll d=1;while(d<=B){ll L=B/d;ll R=B/(d+1);S.insert(R+1);if(R==0)break;d=B/R;}d=1;while(d<=A){ll L=A/d;ll R=A/(d+1);S.insert(R+1);if(R==0)break;d=A/R;}vector<ll> D;for(int s:S)D.push_back(s);ll dn=D.size();ll an=0;for(int i=0;i<dn-1;i++){ll f=B/D[i]-A/D[i];ll res=0;if(f==0){// res=D[i+1]-D[i];}else res=max(D[i+1]-max(D[i],(B-A+f-1)/f),0ll);an+=res;}cout<<an<<endl;;}int main(){ll T;cin>>T;while(T--)solve();}