結果

問題 No.813 ユキちゃんの冒険
ユーザー akakimidoriakakimidori
提出日時 2019-04-12 22:01:14
言語 C
(gcc 12.3.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 932 bytes
コンパイル時間 598 ms
コンパイル使用メモリ 29,788 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-30 13:25:09
合計ジャッジ時間 2,330 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 6 ms
4,384 KB
testcase_03 AC 6 ms
4,380 KB
testcase_04 AC 16 ms
4,380 KB
testcase_05 AC 24 ms
4,380 KB
testcase_06 AC 12 ms
4,380 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 93 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 8 ms
4,380 KB
testcase_11 AC 5 ms
4,384 KB
testcase_12 AC 48 ms
4,380 KB
testcase_13 AC 10 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 83 ms
4,384 KB
testcase_16 AC 15 ms
4,380 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 84 ms
4,380 KB
testcase_20 AC 6 ms
4,376 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 140 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>

typedef int32_t i32;

#define POS(dir,j) ((dir) * (n + 2) + (j))

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  double p, q;
  scanf ("%lf%lf", &p, &q);
  double *now = (double *) calloc (2 * (n + 2), sizeof (double));
  double *next = (double *) calloc (2 * (n + 2), sizeof (double));
  now[POS(0, 1)] = 1;
  double ans = 0;
  for (i32 iter = 0; iter < 5000; iter++) {
    memset (next, 0, sizeof (double) * 2 * (n + 2));
    for (i32 dir = 0; dir < 2; dir++) {
      i32 dx = dir == 0 ? 1 : -1;
      for (i32 i = 1; i <= n; ++i) {
	next[POS(dir, i + dx)] += q * now[POS(dir, i)];
	next[POS(dir ^ 1, i - dx)] += p * now[POS(dir, i)];
      }
    }
    memcpy (now, next, sizeof (double) * 2 * (n + 2));
    ans += next[POS(0, 0)] + next[POS(1, 0)];
  }
  printf ("%.6f\n", ans);
}

int main (void) {
  run ();
  return 0;
}
0