結果

問題 No.2461 一点張り
ユーザー 👑 chro_96chro_96
提出日時 2023-09-08 21:34:29
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 426 bytes
コンパイル時間 224 ms
コンパイル使用メモリ 28,488 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-08 21:34:30
合計ジャッジ時間 847 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>

int main () {
  int t = 0;
  double p = 0.0;
  int k = 0;
  
  int res = 0;
  
  res = scanf("%d", &t);
  while (t > 0) {
    double ans = 0.0;
    double acc = 1.0;
    res = scanf("%lf", &p);
    res = scanf("%d", &k);
    for (int i = 0; i < k-1; i++) {
      ans += acc*p*((double)(i+1));
      acc *= 1.0-p;
    }
    ans += acc*((double)k);
    printf("%.16lf\n", ans);
    t--;
  }
  
  return 0;
}
0