結果

問題 No.1200 お菓子配り-3
ユーザー milanis48663220milanis48663220
提出日時 2020-09-01 01:36:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 752 ms / 4,000 ms
コード長 1,366 bytes
コンパイル時間 913 ms
コンパイル使用メモリ 82,640 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-01 00:20:59
合計ジャッジ時間 6,784 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 3 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 5 ms
6,940 KB
testcase_08 AC 5 ms
6,944 KB
testcase_09 AC 5 ms
6,940 KB
testcase_10 AC 6 ms
6,940 KB
testcase_11 AC 4 ms
6,940 KB
testcase_12 AC 36 ms
6,940 KB
testcase_13 AC 36 ms
6,940 KB
testcase_14 AC 36 ms
6,940 KB
testcase_15 AC 37 ms
6,940 KB
testcase_16 AC 36 ms
6,944 KB
testcase_17 AC 125 ms
6,944 KB
testcase_18 AC 184 ms
6,944 KB
testcase_19 AC 44 ms
6,940 KB
testcase_20 AC 350 ms
6,940 KB
testcase_21 AC 349 ms
6,944 KB
testcase_22 AC 408 ms
6,940 KB
testcase_23 AC 349 ms
6,940 KB
testcase_24 AC 338 ms
6,940 KB
testcase_25 AC 339 ms
6,944 KB
testcase_26 AC 339 ms
6,944 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 AC 273 ms
6,940 KB
testcase_29 AC 749 ms
6,940 KB
testcase_30 AC 752 ms
6,940 KB
testcase_31 AC 2 ms
6,944 KB
testcase_32 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

void solve(){
    int x, y; cin >> x >> y;
    if(x < y) swap(x, y);
    if(x == y){
        int ans = 0;
        // a = 1
        ans += x-1;
        // b = c
        for(int i = 1; i*i <= x; i++){
            if(x%i == 0) {
                if(i != 1)ans++;
                if(i*i != x) ans++;
            }
        }
        if(x%2 == 0) ans--;
        cout << ans << endl;
        return;
    }
    int ans = 0;
    for(int s = 1; s*s <= x-y; s++){
        if((x-y)%s != 0) continue;
        {
            int t_ = (x-y)/s;
            int a = s+1;
            if((x+y)%(a+1) == 0){
                int t = (x+y)/(a+1);
                if(t > t_ && t%2 == t_%2) {
                    ans++;
                }
            }
        }
        if(s*s != x-y){
            int t_ = s;
            int a = (x-y)/t_+1;
            if((x+y)%(a+1) == 0){
                int t = (x+y)/(a+1);
                if(t > t_ && t%2 == t_%2) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int s; cin >> s;
    for(int i = 0; i < s; i++) solve();
}
0