結果

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

コンパイルメッセージ
main.cpp: In function ‘i64 calc(i64)’:
main.cpp:7:20: error: ‘sqrt’ was not declared in this scope
    7 |   return i64((-1 + sqrt(1 + 4*d)) / 2.0);
      |                    ^~~~
main.cpp: In function ‘int main()’:
main.cpp:15:29: error: ‘pow’ was not declared in this scope
   15 |   const i64 MAX_VALUE = i64(pow(10, 18));
      |                             ^~~
main.cpp:17:17: error: ‘sqrt’ was not declared in this scope
   17 |   for(i64 k=i64(sqrt(MAX_VALUE)), cnt=0; cnt<N; --k) {
      |                 ^~~~
main.cpp:17:42: error: ‘cnt’ was not declared in this scope; did you mean ‘int’?
   17 |   for(i64 k=i64(sqrt(MAX_VALUE)), cnt=0; cnt<N; --k) {
      |                                          ^~~
      |                                          int

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;
using i64 = long long;

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

bool is_correct(i64 t, i64 d) {
  return t*t + t <= d && d < (t+1)*(t+1) + (t+1);
}

int main(void) {
  const i64 MAX_VALUE = i64(pow(10, 18));
  const int N = 100000;
  for(i64 k=i64(sqrt(MAX_VALUE)), cnt=0; cnt<N; --k) {
    for(i64 d=k*k+k-1; cnt<N; ++cnt, --d) {
      if(!(1 <= d && d <= MAX_VALUE)) { break; }
      if(is_correct(calc(d), d)) { break; }
      printf("%lld\n", d);
    }
  }
  return 0;
}
0