結果
問題 | No.67 よくある棒を切る問題 (1) |
ユーザー |
|
提出日時 | 2017-12-28 11:06:04 |
言語 | C90 (gcc 12.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 513 bytes |
コンパイル時間 | 273 ms |
コンパイル使用メモリ | 21,888 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-21 08:39:55 |
合計ジャッジ時間 | 4,374 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 5 RE * 26 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:10:25: warning: format ‘%d’ expects argument of type ‘int *’, but argument 2 has type ‘long int *’ [-Wformat=] 10 | scanf("%d",&L[i]); | ~^ ~~~~~ | | | | | long int * | int * | %ld main.c:12:17: warning: format ‘%d’ expects argument of type ‘int *’, but argument 2 has type ‘long int *’ [-Wformat=] 12 | scanf("%d",&K); | ~^ ~~ | | | | | long int * | int * | %ld main.c:8:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | scanf("%d",&N); | ^~~~~~~~~~~~~~ main.c:10:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | scanf("%d",&L[i]); | ^~~~~~~~~~~~~~~~~ main.c:12:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf("%d",&K); | ^~~~~~~~~~~~~~
ソースコード
#include <stdio.h> long int K; unsigned N; long int L[10000]; int C(int); void solve(); int main(){ scanf("%d",&N); for(int i=0;i<N;i++){ scanf("%d",&L[i]); } scanf("%d",&K); solve(); } int C(int x){ int num = 0; for(int i=0;i<N;i++){ num += (int)(L[i] / x ); } if(num >= K){ return 1; }else{ return 0; } } void solve() { double lb =0; double ub = 1000; for(int i =0; i<1000; i++){ double mid = (lb+ub)/2; if(C(mid) == 1){ lb = mid; }else{ ub = mid; } } printf("%f\n",lb); }