結果

問題 No.1200 お菓子配り-3
ユーザー kappybar
提出日時 2020-08-28 21:48:08
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 834 bytes
コンパイル時間 1,836 ms
コンパイル使用メモリ 170,224 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-14 14:33:27
合計ジャッジ時間 27,447 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 4 WA * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int t;
    scanf("%d",&t);
    while(t--){
        ll x,y;
        scanf("%lld%lld",&x,&y);
        ll z = x + y;
        vector<ll> v;
        for(ll i=1;i*i<=z;i++){
            if(z%i==0){
                v.push_back(i);
                if(i!=z/i) v.push_back(z/i);
            }
        }
        ll ans = 0;
        for(ll p:v){
            if(p==1) continue;
            ll b = x/(p-1),c = x%(p-1);
            if(y==(p-1)*c+b) ++ans;
        }
        printf("%lld\n",ans);
    }
    return 0;
}
0