結果
問題 | No.2882 Comeback |
ユーザー |
|
提出日時 | 2024-09-08 13:14:50 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 13 ms / 2,000 ms |
コード長 | 811 bytes |
コンパイル時間 | 1,927 ms |
コンパイル使用メモリ | 192,752 KB |
最終ジャッジ日時 | 2025-02-24 05:29:23 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main() {ios_base::sync_with_stdio(false);cin.tie(nullptr);int T; cin >> T;while(T--){int A,B; cin >> A >> B;int answer = 0;int i;for(i=1; i*i<=B; i++) if(A%i >= B%i) answer++;while(i <= B){int am = A%i,bm = B%i;int av = A/i,bv = B/i;int next = min(B-i+1,bm/bv+1);if(av) next = min(next,am/av+1);if(am >= bm && av <= bv) answer += next;else if(am < bm && av >= bv) answer += 0;else if(am >= bm && av > bv) answer += min(next,(am-bm)/(av-bv)+1);else if(am < bm && av < bv) answer += max(0,next-(bm-am+bv-av-1)/(bv-av));i += next;}cout << answer << endl;}}