結果

問題 No.413 +5,000,000pts
ユーザー yuppe19 😺yuppe19 😺
提出日時 2016-06-06 16:33:39
言語 C++11
(gcc 11.4.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 516 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 52,304 KB
最終ジャッジ日時 2024-04-27 02:20:59
合計ジャッジ時間 699 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: In function ‘ll calc(ll)’:
main.cpp:7:21: error: ‘sqrt’ was not declared in this scope
    7 |   return (ll)((-1 + sqrt(1 + 4*d)) / 2.0);
      |                     ^~~~
main.cpp: In function ‘ll correct(ll)’:
main.cpp:11:21: error: ‘sqrt’ was not declared in this scope
   11 |   return (ll)((-1 + sqrt(1+4*(long double)d)) / 2.0);
      |                     ^~~~
main.cpp: In function ‘int main()’:
main.cpp:15:27: error: ‘pow’ was not declared in this scope
   15 |   const ll MAX_VALUE = ll(pow(10, 18));
      |                           ^~~

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

ll calc(ll d) {
  return (ll)((-1 + sqrt(1 + 4*d)) / 2.0);
}

ll correct(ll d) {
  return (ll)((-1 + sqrt(1+4*(long double)d)) / 2.0);
}

int main(void) {
  const ll MAX_VALUE = ll(pow(10, 18));
  const int N = 100000;
  for(ll k=82345678LL, cnt=0; cnt<N; ++k) {
    ll d = k*k + k - 1;
    if(!(1 <= d && d <= MAX_VALUE)) { continue; }
    if(calc(d) != correct(d)) {
      ++cnt;
      cout << d << endl;
    }
  }
  return 0;
}
0