結果

問題 No.1200 お菓子配り-3
ユーザー KKT89KKT89
提出日時 2020-08-28 21:54:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 845 bytes
コンパイル時間 991 ms
コンパイル使用メモリ 98,392 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-26 22:48:27
合計ジャッジ時間 10,018 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 3 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 8 ms
5,376 KB
testcase_08 AC 8 ms
5,376 KB
testcase_09 AC 8 ms
5,376 KB
testcase_10 AC 8 ms
5,376 KB
testcase_11 AC 8 ms
5,376 KB
testcase_12 AC 63 ms
5,376 KB
testcase_13 AC 65 ms
5,376 KB
testcase_14 AC 65 ms
5,376 KB
testcase_15 AC 65 ms
5,376 KB
testcase_16 AC 65 ms
5,376 KB
testcase_17 AC 223 ms
5,376 KB
testcase_18 AC 325 ms
5,376 KB
testcase_19 AC 76 ms
5,376 KB
testcase_20 AC 623 ms
5,376 KB
testcase_21 AC 616 ms
5,376 KB
testcase_22 AC 732 ms
5,376 KB
testcase_23 AC 618 ms
5,376 KB
testcase_24 AC 621 ms
5,376 KB
testcase_25 AC 622 ms
5,376 KB
testcase_26 AC 630 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 1,027 ms
5,376 KB
testcase_29 AC 766 ms
5,376 KB
testcase_30 AC 761 ms
5,376 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

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-j!=0||Y-j!=0)return 0;
        return j-2;
    }
    else{
        if((X-j)%(a-1))return 0;
        if((Y-j)%(a-1))return 0;
        ll b=(X-j)/(a-1);
        ll c=(Y-j)/(a-1);
        return b>=1&&c>=1&&b+c==j;
    }
}


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)res+=count_res(x/i,i);
            }
        }
        cout << res << "\n";
    }
}
0