結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー あり
提出日時 2023-02-20 12:18:30
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 686 bytes
コンパイル時間 819 ms
コンパイル使用メモリ 86,644 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2025-03-03 12:07:10
合計ジャッジ時間 7,442 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:34:17: warning: use of ‘ll’ length modifier with ‘f’ type character has either no effect or undefined behavior [-Wformat=]
   34 |   printf("%.15llf\n", ok);
      |                 ^

ソースコード

diff #

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <queue>
#include <cassert>
#include <cmath>
#include <bitset>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<double> l(n);
  for (int i = 0; i < n; i++) cin >> l[i];
  long long k;
  cin >> k;

  double ok = 0;
  double ng = 1e10;
  for (int j = 0; j < 100; j++) {
    double x = (ok+ng)/2.0;
    long long cnt = 0;
    for (int i = 0; i < n; i++) cnt += l[i]/x;
    //cout << "x = " << x << ", cnt = " << cnt << endl;
    if (cnt >= k) ok = x;
    else ng = x;
  }
  printf("%.15llf\n", ok);
}
0