結果

問題 No.1200 お菓子配り-3
ユーザー abc3abc3
提出日時 2020-08-29 20:44:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,067 bytes
コンパイル時間 1,495 ms
コンパイル使用メモリ 170,452 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-27 01:19:40
合計ジャッジ時間 10,640 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,816 KB
testcase_02 WA -
testcase_03 AC 3 ms
6,944 KB
testcase_04 WA -
testcase_05 AC 2 ms
6,944 KB
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 1,042 ms
6,940 KB
testcase_29 AC 769 ms
6,940 KB
testcase_30 AC 783 ms
6,940 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;
const int INF=1001001001;

int f(int P,int Q){

  vector<int>A;
  for(int i=3;i*i<=P;i++){
    int s=P/i;
    if(P%i==0){if(Q%(i-2)==0&& s > Q/(i-2)){A.push_back(i-1);}
               if(i!=s&&Q%(s-2)==0&&P/s>Q/(s-2)){A.push_back(P/i-1);}
    }
  }

  int n=A.size();
  int cnt=0;
  for(int i=0;i<n;i++){
    int v=Q/(A[i]-1);
    int w=P/(A[i]+1);
    int B=(v+w)/2;
    int C=(w-v)/2;
    if((A[i]-1)*(B-C)==Q&&(A[i]+1)*(B+C)==P){cnt++;}
  }
  return cnt;
}


int main() {
  int N;
  cin>>N;
  vector<int>x(N),y(N);
  for(int i=0;i<N;i++){
    cin>>x[i]>>y[i];
  }
  int cnt=0;
  for(int i=0;i<N;i++){
    int P=x[i]+y[i];
    int Q=x[i]-y[i];
    if(y[i]!=x[i]){
      cout<<f(P,Q)<<endl;
    }
    else {
      P=Q;
      cout<<f(P,Q)<<endl;
    }
  }
  return 0;  
}
0