結果

問題 No.1200 お菓子配り-3
ユーザー KKT89KKT89
提出日時 2020-09-26 08:46:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 957 ms / 4,000 ms
コード長 819 bytes
コンパイル時間 1,040 ms
コンパイル使用メモリ 98,952 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-01 00:25:24
合計ジャッジ時間 8,960 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 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 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 7 ms
6,944 KB
testcase_08 AC 7 ms
6,940 KB
testcase_09 AC 7 ms
6,944 KB
testcase_10 AC 7 ms
6,940 KB
testcase_11 AC 8 ms
6,940 KB
testcase_12 AC 58 ms
6,940 KB
testcase_13 AC 61 ms
6,944 KB
testcase_14 AC 60 ms
6,940 KB
testcase_15 AC 58 ms
6,940 KB
testcase_16 AC 58 ms
6,940 KB
testcase_17 AC 201 ms
6,944 KB
testcase_18 AC 291 ms
6,940 KB
testcase_19 AC 68 ms
6,940 KB
testcase_20 AC 555 ms
6,944 KB
testcase_21 AC 562 ms
6,944 KB
testcase_22 AC 667 ms
6,940 KB
testcase_23 AC 564 ms
6,940 KB
testcase_24 AC 573 ms
6,944 KB
testcase_25 AC 610 ms
6,944 KB
testcase_26 AC 596 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 957 ms
6,944 KB
testcase_29 AC 691 ms
6,940 KB
testcase_30 AC 683 ms
6,940 KB
testcase_31 AC 1 ms
6,940 KB
testcase_32 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <map>
using namespace std;
typedef long long int ll;

ll X,Y;

ll count_res(ll i,ll j){
    if(j<2)return 0;
    ll A=i-1;
    if(A==1){
        if(X!=Y)return 0;
        else return X-1;
    }
    if((A*Y-X)%(A*A-1))return 0;
    ll C=(A*Y-X)/(A*A-1);
    if(C<1)return 0;
    if((X-C)%A)return 0;
    ll B=(X-C)/A;
    return B>=1;
}


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int q; cin >> q;
    while(q--){
        cin >> X >> Y;
        int x=X+Y;
        ll res=0;
        for(int i=2;i*i<=x;i++){
            if(x%i==0){
                res+=count_res(i,x/i);
                if(x/i!=i&&x/i>=2)res+=count_res(x/i,i);
            }
        }
        cout << res << "\n";
    }
}
0