結果

問題 No.2368 I love a square root of 2
ユーザー SSRSSSRS
提出日時 2023-06-30 22:26:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 618 bytes
コンパイル時間 1,443 ms
コンパイル使用メモリ 164,408 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-21 16:35:15
合計ジャッジ時間 2,783 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,376 KB
testcase_01 AC 5 ms
4,376 KB
testcase_02 AC 60 ms
4,380 KB
testcase_03 AC 5 ms
4,376 KB
testcase_04 AC 5 ms
4,376 KB
testcase_05 AC 5 ms
4,376 KB
testcase_06 AC 5 ms
4,380 KB
testcase_07 AC 5 ms
4,380 KB
testcase_08 AC 5 ms
4,376 KB
testcase_09 AC 5 ms
4,376 KB
testcase_10 AC 5 ms
4,376 KB
testcase_11 AC 5 ms
4,376 KB
testcase_12 AC 5 ms
4,376 KB
testcase_13 AC 48 ms
4,376 KB
testcase_14 AC 49 ms
4,376 KB
testcase_15 AC 54 ms
4,380 KB
testcase_16 AC 37 ms
4,380 KB
testcase_17 AC 6 ms
4,380 KB
testcase_18 AC 6 ms
4,384 KB
testcase_19 AC 7 ms
4,380 KB
testcase_20 AC 6 ms
4,376 KB
testcase_21 AC 59 ms
4,380 KB
testcase_22 AC 57 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:32:23: 警告: ‘cb’ may be used uninitialized [-Wmaybe-uninitialized]
   32 |   cout << a << ' ' << b << endl;
      |                       ^
main.cpp:13:13: 備考: ‘cb’ はここで定義されています
   13 |     int ca, cb;
      |             ^~
main.cpp:32:16: 警告: ‘ca’ may be used uninitialized [-Wmaybe-uninitialized]
   32 |   cout << a << ' ' << b << endl;
      |                ^~~
main.cpp:13:9: 備考: ‘ca’ はここで定義されています
   13 |     int ca, cb;
      |         ^~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const double INF = 1000000;
int main(){
  long long N;
  cin >> N;
  double tv = 0, fv = INF;
  int a, b;
  for (int i = 0; i < 100; i++){
    double mid = (tv + fv) / 2;
    double mx = -1;
    long long cnt = 0;
    int ca, cb;
    for (int j = 0; j <= mid; j++){
      int f = (mid - j) / sqrt(2);
      cnt += f + 1;
      double x = j + f * sqrt(2);
      if (x > mx){
        mx = x;
        ca = j;
        cb = f;
      }
    }
    if (cnt <= N){
      tv = mid;
      a = ca;
      b = cb;
    } else {
      fv = mid;
    }
  }
  cout << a << ' ' << b << endl;
}
0