結果

問題 No.550 夏休みの思い出(1)
ユーザー beetbeet
提出日時 2017-07-28 23:23:45
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,803 bytes
コンパイル時間 1,662 ms
コンパイル使用メモリ 169,060 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-18 11:50:59
合計ジャッジ時間 3,525 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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,P,Q;
Int calc(Int x){
  return x*x*x+A*x*x+B*x+C;
}
Int calc2(Int x){
  return x*x+P*x+Q;
}
signed main(){
  cin>>a>>b>>c;
  A=a;B=b;C=c;
  set<Int> ans;
  for(Int i=-1e6;i<1e6;i++){
    if(calc(i)==0) ans.insert(i);
  }
  if((int)ans.size()<3){
    Int k=*ans.begin();
    P=A+k,Q=k*(A+k);
    {
      Int L=INT_MIN,R=-P/2;
      for(Int i=-1000;i<1000;i++)
	if(calc(R+i)==0) ans.insert(R+i);
      while(L+1<R){
	Int M=(L+R)/2;
	if(calc(M)>=0) L=M;
	else R=M;
	for(Int i=-1000;i<1000;i++)
	  if(calc(R+i)==0) ans.insert(R+i);
      }
      for(Int i=-1000;i<1000;i++)
	if(calc(R+i)==0) ans.insert(R+i);
    }
    {
      Int L=INT_MIN,R=-P/2;
      for(Int i=-1000;i<1000;i++)
	if(calc(R+i)==0) ans.insert(R+i);
      while(L+1<R){
	Int M=(L+R)/2;
	if(calc(M)<=0) L=M;
	else R=M;
	for(Int i=-1000;i<1000;i++)
	  if(calc(R+i)==0) ans.insert(R+i);
      }
      for(Int i=-1000;i<1000;i++)
	if(calc(R+i)==0) ans.insert(R+i);
    }
  }
  bool flg=0;
  for(Int i:ans){
    if(flg) cout<<" ";
    cout<<i;
    flg=1;
  }
  cout<<endl;
  return 0;
}
0