結果
問題 | No.67 よくある棒を切る問題 (1) |
ユーザー |
![]() |
提出日時 | 2016-12-12 23:57:04 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 187 ms / 5,000 ms |
コード長 | 917 bytes |
コンパイル時間 | 1,329 ms |
コンパイル使用メモリ | 159,812 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2025-03-03 10:39:35 |
合計ジャッジ時間 | 6,824 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:25:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 25 | scanf("%ld", &n); | ~~~~~^~~~~~~~~~~ main.cpp:27:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 27 | scanf("%ld", &xs[i]); | ~~~~~^~~~~~~~~~~~~~~ main.cpp:29:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 29 | scanf("%ld", &k); | ~~~~~^~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> #ifndef LOCAL_ #define fprintf if( false ) fprintf #endif // LOCAL_ #define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1); #define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1); #define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1); long n; long xs[212345]; long k; bool check(double x) { if( x == 0 ) return false; long res = 0; for(int i = 0; i < n; ++i) { res += (xs[i] / x + 1e-10); } dumpl(res); return k <= res; } int main() { scanf("%ld", &n); for(int i = 0; i < n; ++i) { scanf("%ld", &xs[i]); } scanf("%ld", &k); double z = 0; double diff = (1LL << 40); for(int i = 120; i >= 0; --i) { double nz = z + diff; diff /= 2; dumpd(nz); if( check(nz) ) { z = nz; continue; } } printf("%.20lf\n", z); return 0; }