結果

問題 No.550 夏休みの思い出(1)
ユーザー beetbeet
提出日時 2017-07-28 22:59:55
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,928 bytes
コンパイル時間 1,477 ms
コンパイル使用メモリ 163,472 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-18 11:20:55
合計ジャッジ時間 5,430 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 WA -
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 1 ms
6,940 KB
testcase_17 AC 1 ms
6,940 KB
testcase_18 AC 1 ms
6,944 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 1 ms
6,944 KB
testcase_21 AC 1 ms
6,940 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 1 ms
6,940 KB
testcase_24 AC 1 ms
6,944 KB
testcase_25 AC 1 ms
6,940 KB
testcase_26 AC 1 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 1 ms
6,944 KB
testcase_29 AC 1 ms
6,940 KB
testcase_30 AC 2 ms
6,944 KB
testcase_31 AC 1 ms
6,940 KB
testcase_32 AC 1 ms
6,944 KB
testcase_33 AC 1 ms
6,940 KB
testcase_34 AC 1 ms
6,940 KB
testcase_35 AC 1 ms
6,940 KB
testcase_36 AC 1 ms
6,944 KB
testcase_37 AC 1 ms
6,940 KB
testcase_38 AC 1 ms
6,940 KB
testcase_39 AC 2 ms
6,944 KB
testcase_40 AC 1 ms
6,940 KB
testcase_41 AC 1 ms
6,940 KB
testcase_42 AC 1 ms
6,944 KB
testcase_43 AC 1 ms
6,940 KB
testcase_44 AC 1 ms
6,940 KB
testcase_45 AC 1 ms
6,944 KB
testcase_46 AC 1 ms
6,944 KB
testcase_47 AC 1 ms
6,940 KB
testcase_48 AC 1 ms
6,940 KB
testcase_49 AC 1,242 ms
6,944 KB
testcase_50 AC 1,237 ms
6,944 KB
testcase_51 AC 2 ms
6,940 KB
testcase_52 AC 2 ms
6,944 KB
testcase_53 AC 2 ms
6,944 KB
testcase_54 AC 1 ms
6,940 KB
testcase_55 AC 1 ms
6,940 KB
testcase_56 AC 1 ms
6,944 KB
testcase_57 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
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;
}
using Int = __int128;
Int sqrt(Int A){
  Int L = 0, R = LLONG_MAX;
  while(L+1<R){
    Int M=(L+R)/2;
    if(M*M<=A) L=M;
    else R=M;
  }
  return L;
}
int a,b,c;
Int A,B,C;
Int calc(Int x){
  return x*x*x+A*x*x+B*x+C;
}
signed main(){
  cin>>a>>b>>c;
  A=a;B=b;C=c;
  if(abs(a)<1e7&&abs(b)<1e7&&abs(c)<1e7){
    bool flg=0;
    for(int i=-1e8;i<1e8;i++){
      if(calc(i)==0){
	if(flg) cout<<" ";
	cout<<i,flg=1;
      }
    }
    cout<<endl;
    return 0;
  }
  Int P=(A-sqrt(A*A-3*B))/3,Q=(A+sqrt(A*A-3*B))/3;
  //cout<<A*A-3*B<<" "<<sqrt(A*A-3*B)<<":"<<sqrt(A*A-3*B)*sqrt(A*A-3*B)<<endl;
  //cout<<P<<" "<<Q<<endl;
  //cout<<calc(P)<<" "<<calc(Q)<<endl;
  //cout<<calc(-114514)<<endl;
  {
    Int L=INT_MIN,R=-Q;
    //cout<<calc(L)<<" "<<calc(R)<<endl;
    while(L+1<R){
      Int M=(L+R)/2;
      //cout<<M<<":"<<calc(M)<<endl;
      if(calc(M)<=0) L=M;
      else R=M;
    }
    cout<<L<<" ";
  }
  {
    Int L=-Q,R=-P;
    //cout<<calc(L)<<" "<<calc(R)<<endl;
    while(L+1<R){
      Int M=(L+R)/2;
      //cout<<M<<":"<<calc(M)<<endl;
      if(calc(M)>=0) L=M;
      else R=M;
    }
    cout<<L<<" ";
  }
  {
    Int L=-P,R=INT_MAX;
    //cout<<calc(L)<<" "<<calc(R)<<endl;
    while(L+1<R){
      Int M=(L+R)/2;
      //cout<<M<<":"<<calc(M)<<endl;
      if(calc(M)<=0) L=M;
      else R=M;
    }
    cout<<L<<endl;
  }
  return 0;
}
0