結果

問題 No.1200 お菓子配り-3
ユーザー yurukumoyurukumo
提出日時 2021-08-01 22:15:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,077 bytes
コンパイル時間 3,918 ms
コンパイル使用メモリ 226,556 KB
実行使用メモリ 4,480 KB
最終ジャッジ日時 2023-10-14 19:03:42
合計ジャッジ時間 21,372 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 872 ms
4,352 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
#define int long long
#define endl "\n"
#define all(n) n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
#define rep(i, s, n) for (int i = s; i < (int)(n); i++)
#define floatset(n) fixed<<setprecision(n)
#define rangeout(x,y,h,w) (x<0||y<0||h-1<x||w-1<y)
using namespace std;
using namespace atcoder;
template<class T>using vec=vector<T>;
template<class T>using min_queue=priority_queue<T,vector<T>,greater<T>>;
using ll = long long;
using ld = long double;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;
struct Edge1{ll to,cost;};
using WGraph = vec<vec<Edge1>>;
struct BellEdge{ll from,to,cost;};
using BGraph=vec<BellEdge>;
constexpr ll INF = 1e18;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
template<typename T>
bool chmin(T&a,T b){return a>b?a=b,true:false;}
template<typename T>
bool chmax(T&a,T b){return a<b?a=b,true:false;}
bool Flag(int bit,int i){return (bit&(1LL<<i));}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
int g(int X){
    int res=0;
    for(int i=1;i*i<=X;i++){
        if(X%i==0){
            if((X/i)==i){
                if(1<i)res++;
            }else{
                if(1<i)res++;
                if(1<(X/i))res++;
            }
        }
    }
    return res;
}
void solve(){
    int X,Y;
    cin>>X>>Y;
    if(X==Y){
        cout<<g(X)<<endl;
        return;
    }
    if(X<Y)swap(X,Y);
    int sa=X-Y;
    auto f=[&](int A,int a)->bool{
        //A-1が渡されるのでインクリメント
        A++;
        if((X-A*a)%(A+1)==0)return true;
        else return false;
    };
    int ans=0;
    for(int i=1;i*i<=sa;i++){
        if(sa%i==0){
            if((X/i)==i){
                if(f(i,sa/i))ans++;
            }else{
                if(f(i,sa/i))ans++;
                if(f(sa/i,i))ans++;
            }
        }
    }
    cout<<ans<<endl;
}
signed main(){
    int S;
    cin>>S;
    while(S--)solve();
}
0