結果

問題 No.1203 お菓子ゲーム
ユーザー 👑 PCTprobabilityPCTprobability
提出日時 2020-07-23 21:26:04
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,674 bytes
コンパイル時間 1,207 ms
コンパイル使用メモリ 83,904 KB
実行使用メモリ 6,940 KB
最終ジャッジ日時 2024-04-25 03:42:14
合計ジャッジ時間 17,871 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 225 ms
5,248 KB
testcase_01 AC 308 ms
5,376 KB
testcase_02 AC 100 ms
5,376 KB
testcase_03 AC 377 ms
5,376 KB
testcase_04 AC 101 ms
5,376 KB
testcase_05 AC 433 ms
5,376 KB
testcase_06 AC 270 ms
5,376 KB
testcase_07 AC 407 ms
5,376 KB
testcase_08 AC 218 ms
5,376 KB
testcase_09 AC 201 ms
5,376 KB
testcase_10 AC 428 ms
5,376 KB
testcase_11 AC 101 ms
5,376 KB
testcase_12 AC 252 ms
5,376 KB
testcase_13 AC 180 ms
5,376 KB
testcase_14 AC 222 ms
5,376 KB
testcase_15 AC 469 ms
5,376 KB
testcase_16 AC 165 ms
5,376 KB
testcase_17 AC 357 ms
5,376 KB
testcase_18 AC 4 ms
5,376 KB
testcase_19 AC 41 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 486 ms
5,376 KB
testcase_31 AC 511 ms
5,376 KB
testcase_32 AC 483 ms
5,376 KB
testcase_33 AC 485 ms
5,376 KB
testcase_34 AC 487 ms
5,376 KB
testcase_35 AC 487 ms
5,376 KB
testcase_36 AC 483 ms
5,376 KB
testcase_37 AC 485 ms
5,376 KB
testcase_38 AC 487 ms
5,376 KB
testcase_39 AC 483 ms
5,376 KB
testcase_40 AC 515 ms
5,376 KB
testcase_41 AC 515 ms
5,376 KB
testcase_42 AC 514 ms
5,376 KB
testcase_43 AC 511 ms
5,376 KB
testcase_44 AC 511 ms
5,376 KB
testcase_45 AC 515 ms
5,376 KB
testcase_46 AC 515 ms
5,376 KB
testcase_47 AC 513 ms
5,376 KB
testcase_48 AC 515 ms
5,376 KB
testcase_49 AC 512 ms
5,376 KB
testcase_50 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <random>
using namespace std;
using ll = 	__int128;
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}

__int128 p(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
    if ('0' <= s[i] && s[i] <= '9')
      ret = 10 * ret + s[i] - '0';
  return ret;
}
ll gcds(ll a,ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcds(b, a%b));
   }
}
ll si(ll a,ll b){
  ll r=gcds(a,b);
  return a/r;
}
ll bo(ll a,ll b){
  ll r=gcds(a,b);
  return b/r;
}
int main(){
    ll q,w;
  string o;
  cin>>o;
  ll r;
  ll s=p(o);
 ll a,b;
  ll ans;
  string x,y;
  for(ll i=0;i<s;i++){
    cin>>x>>y;
  a=p(x);
    b=p(y);
    if(2*a>b){
      a=b-a;
    }
ans=100000000/b;
   
    for(ll i=1;i*i<=b;i++){
        
      if(b%i==0){
          if(i%2==1){
          q=(b*(i*i-1))/(2*a*i);
      if((b*(i*i-1))%(2*a*i)==0&&(b*(i*i-1))/(2*a*i)>i&&q>=1&&q<=100000000){
        ans++;
      }
          }
          
      r=b/i;
      if(r!=i){
          if(r%2==1){
          w=(b*(r*r-1))/(2*a*r);
      if((b*(r*r-1))%(2*a*r)==0&&(b*(r*r-1))/(2*a)>r&&w>=1&&w<=100000000){
        ans++;
      }
          }
      }
    }
    }
    cout<<ans<<endl;
  }
}
0