結果

問題 No.2461 一点張り
ユーザー 👑 NachiaNachia
提出日時 2021-05-09 15:56:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 784 bytes
コンパイル時間 5,556 ms
コンパイル使用メモリ 209,716 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-01 01:07:43
合計ジャッジ時間 6,257 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "testlib.h"

#include <stdio.h>

const int maxK = 10'000'000;

int main() {
  registerValidation();
  
  int T = inf.readInt(1,1000,"T");
  if(T!=4 && T!=1000) 
    inf.quit(_wa, ("Integer parameter [name=T] equals to " + vtos(T) +
                           ", violates the restriction \"T=4 OR 1000\"").c_str());
  inf.readEoln();

  for(int testcase_id=1; testcase_id<=T; testcase_id++){
    std::string testcase_id_s = " for testcase " + vtos(testcase_id);
    double p = inf.readStrictReal(0.0,1.0,1,10,"p"+testcase_id_s);
    inf.readSpace();
    int K = inf.readInt(0,maxK,"K"+testcase_id_s);
    inf.readEoln();

		if(p == 0){
			printf("%d\n",K);
		}
		else{
			double ans = (1.0-pow(1.0-p,K)) / p;
			printf("%.12f\n",ans);
		}
  }

  inf.readEof();
  return 0;
}
0