結果

問題 No.1203 お菓子ゲーム
ユーザー 👑 PCTprobabilityPCTprobability
提出日時 2020-07-23 20:58:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,586 bytes
コンパイル時間 813 ms
コンパイル使用メモリ 84,068 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 03:41:29
合計ジャッジ時間 9,639 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
5,248 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 52 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 136 ms
5,376 KB
testcase_07 AC 204 ms
5,376 KB
testcase_08 AC 109 ms
5,376 KB
testcase_09 AC 100 ms
5,376 KB
testcase_10 AC 212 ms
5,376 KB
testcase_11 AC 53 ms
5,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 113 ms
5,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 21 ms
5,376 KB
testcase_20 WA -
testcase_21 AC 2 ms
5,376 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 238 ms
5,376 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 240 ms
5,376 KB
testcase_39 WA -
testcase_40 AC 250 ms
5,376 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 253 ms
5,376 KB
testcase_44 WA -
testcase_45 AC 253 ms
5,376 KB
testcase_46 WA -
testcase_47 AC 257 ms
5,376 KB
testcase_48 WA -
testcase_49 AC 256 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 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;
    ll r;
    for(ll i=1;i*i<=b;i=i+2){
      if(b%i==0){
          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){
          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