結果

問題 No.1200 お菓子配り-3
ユーザー 👑 PCTprobabilityPCTprobability
提出日時 2020-08-29 16:59:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,721 ms / 4,000 ms
コード長 1,551 bytes
コンパイル時間 2,360 ms
コンパイル使用メモリ 208,156 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-01 00:10:51
合計ジャッジ時間 18,096 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 13 ms
5,376 KB
testcase_08 AC 14 ms
5,376 KB
testcase_09 AC 13 ms
5,376 KB
testcase_10 AC 13 ms
5,376 KB
testcase_11 AC 13 ms
5,376 KB
testcase_12 AC 111 ms
5,376 KB
testcase_13 AC 113 ms
5,376 KB
testcase_14 AC 113 ms
5,376 KB
testcase_15 AC 113 ms
5,376 KB
testcase_16 AC 112 ms
5,376 KB
testcase_17 AC 402 ms
5,376 KB
testcase_18 AC 575 ms
5,376 KB
testcase_19 AC 134 ms
5,376 KB
testcase_20 AC 1,104 ms
5,376 KB
testcase_21 AC 1,106 ms
5,376 KB
testcase_22 AC 1,313 ms
5,376 KB
testcase_23 AC 1,110 ms
5,376 KB
testcase_24 AC 1,104 ms
5,376 KB
testcase_25 AC 1,099 ms
5,376 KB
testcase_26 AC 1,103 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 1,479 ms
5,376 KB
testcase_29 AC 1,715 ms
5,376 KB
testcase_30 AC 1,721 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int ss(int x,int y){
   int n,m;
    if(x!=y){
      if(x<y){
        swap(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(m/i);
          }
      }
      
  }
         sort(nn.begin(), nn.end());
      sort(mm.begin(), mm.end());
  int ans=0;
  int tmp=0;
  int tmp2;
  int tmp3;
  for(int i=0;i<int(mm.size());i++){
   while(tmp<int(nn.size())&&mm.at(i)+2>=nn.at(tmp)){
       if (mm.at(i)==nn.at(tmp)-2){
           tmp2=nn.at(int(nn.size()-1))/nn.at(tmp);
        tmp3=mm.at(int(mm.size()-1))/mm.at(i);
            if(tmp2>tmp3&&tmp2%2==tmp3%2){
                ans++;
       }
       }
     tmp++;
   }
  }
  return ans;
    }
    else{
      vector<int> o;
        n=2*x;
       int ans=0;
       ans+=max(0,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