結果

問題 No.1200 お菓子配り-3
ユーザー milanis48663220milanis48663220
提出日時 2020-09-01 01:17:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,260 bytes
コンパイル時間 756 ms
コンパイル使用メモリ 82,488 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 11:45:19
合計ジャッジ時間 6,301 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 5 ms
5,376 KB
testcase_08 AC 5 ms
5,376 KB
testcase_09 AC 5 ms
5,376 KB
testcase_10 AC 5 ms
5,376 KB
testcase_11 AC 4 ms
5,376 KB
testcase_12 AC 34 ms
5,376 KB
testcase_13 AC 35 ms
5,376 KB
testcase_14 AC 35 ms
5,376 KB
testcase_15 AC 37 ms
5,376 KB
testcase_16 AC 36 ms
5,376 KB
testcase_17 AC 128 ms
5,376 KB
testcase_18 AC 177 ms
5,376 KB
testcase_19 AC 42 ms
5,376 KB
testcase_20 AC 334 ms
5,376 KB
testcase_21 AC 330 ms
5,376 KB
testcase_22 AC 400 ms
5,376 KB
testcase_23 AC 332 ms
5,376 KB
testcase_24 AC 332 ms
5,376 KB
testcase_25 AC 332 ms
5,376 KB
testcase_26 AC 345 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 277 ms
5,376 KB
testcase_29 AC 723 ms
5,376 KB
testcase_30 AC 728 ms
5,376 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

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 = 3; i*i <= x; i++){
            if(x%i == 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