結果

問題 No.1200 お菓子配り-3
ユーザー bachoppibachoppi
提出日時 2020-08-28 22:15:01
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,213 bytes
コンパイル時間 2,324 ms
コンパイル使用メモリ 120,144 KB
最終ジャッジ日時 2025-01-13 17:59:33
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 29 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793

int main(){
  int S; cin >> S;
  while(S--){
    int x, y; cin >> x >> y; int ans = 0;
    if(x<y) swap(x, y);
    int p = x+y; int m = x-y;
    set<pair<int, int>> pl;
    for(int i=1; i*i<=p; i++){
      if(p%i==0){
        pl.insert({i, 0}); pl.insert({p/i, 0});
      }
    }
    for(int i=1; i*i<=m; i++){
      if(m%i==0){
        pl.insert({i, 1}); pl.insert({m/i, 1});
      }
    }
    for(auto k: pl){
      if(k.second==1){
        if(pl.count({k.first+2, 0})){
          if((p/(k.first+2))%2==(m/k.first)%2 && p/(k.first+2)>(m/k.first)){
            ans++; //cout << k.first << " " << p << " " << m << endl;
          }
        }
      }
    }
    cout << ans << endl;
  }
}
0