結果

問題 No.1200 お菓子配り-3
ユーザー 👑 PCTprobabilityPCTprobability
提出日時 2020-08-29 16:39:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,440 bytes
コンパイル時間 2,221 ms
コンパイル使用メモリ 205,688 KB
実行使用メモリ 13,880 KB
最終ジャッジ日時 2024-04-27 01:09:02
合計ジャッジ時間 11,563 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int ss(long long x,long long y){
    long long n,m;
    if(x!=y){
  n=x+y;
  m=x-y;
  vector<int> nn;
  vector<int> mm;
  for(int i=1;i*i<=n;i++){
      if(n%i==0){
          nn.push_back(i);
          if(n/i!=i){
              nn.push_back(n/i);
          }
      }
      
  }
    for(int i=1;i*i<=m;i++){
      if(m%i==0){
          mm.push_back(i);
          if(m/i!=i){
              mm.push_back(n/i);
          }
      }
      
  }
  long long z=0;
  long long ans=0;
  int tmp=0;
  int tmp2;
  int tmp3;
  for(int i=0;i<mm.size();i++){
   if(mm.at(i)+2>=nn.at(tmp)&&tmp<nn.size()){
       if (mm.at(i)==nn.at(i)-2){
           tmp2=nn.at(nn.size()-1)/nn.at(tmp);
        tmp3=mm.at(mm.size()-1)/mm.at(i);
            if (tmp2>tmp3&&(tmp3-tmp2)%2==0){
                ans++;
                    }
   }
   }
  }
  return ans;
    }
    else{
        n=2*x;
        long long ans=0;
       ans+=max(0ll,x-1);
       for(int i=2;i<=n;i++){
           if(i%2==0&&n%i==0){
               if(((n/i)-1)>=2){
                   ans++;
               }
           }
       }
       return ans;
    }
}
int main() {
 int s;
  cin>>s;
 
  vector<int> x(s);
  vector<int> y(s);
  for(int i=0;i<s;i++){
    cin>>x.at(i);
    cin>>y.at(i);
  }
  for(int i=0;i<s;i++){
    if(x.at(i)<y.at(i)){
      swap(x.at(i),y.at(i));
    }
   
  }
  for(int i=0;i<s;i++){
    cout<<ss(x.at(i),y.at(i))<<endl;
  }
}
0