結果

問題 No.413 +5,000,000pts
ユーザー yuppe19 😺yuppe19 😺
提出日時 2016-06-06 17:25:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 582 ms / 5,000 ms
コード長 1,056 bytes
コンパイル時間 2,509 ms
コンパイル使用メモリ 77,876 KB
実行使用メモリ 63,720 KB
最終ジャッジ日時 2024-04-20 07:14:08
合計ジャッジ時間 3,430 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 582 ms
63,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.*;
import java.util.*;

import static java.lang.Math.*;
import static java.math.BigDecimal.*;

public class Main {
  private static final long MAX_VALUE = (long)pow(10, 18);
  private static final int N = 100000;

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

  private long correct(long d) {
    long lo = 0, hi = d + 1;
    while(hi - lo > 10) {
      long md = (lo + hi) / 2;
      if(md > Integer.MAX_VALUE) { hi = md; continue; }
      if(md*md + md <= d) {
        lo = md;
      } else {
        hi = md;
      }
    }
    for(long t=lo; t<=hi; ++t) {
      if(t*t + t <= d && d < (t+1)*(t+1) + (t+1)) { return t; }
    }
    throw new RuntimeException("(;ω;)");
  }

  private void solve() {
    for(long k=112345678L, cnt=0; cnt<N; ++k) {
      long d = k*k + k - 1;
      if(!(1 <= d && d <= MAX_VALUE)) { continue; }
      if(calc(d) != correct(d)) {
        ++cnt;
        System.out.println(d);
      }
    }
  }

  public static void main(String[] args) {
    new Main().solve();
  }
}
0