結果

問題 No.813 ユキちゃんの冒険
ユーザー akakimidoriakakimidori
提出日時 2019-04-13 07:43:38
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 947 bytes
コンパイル時間 1,977 ms
コンパイル使用メモリ 29,692 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-30 15:10:16
合計ジャッジ時間 7,594 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 26 ms
4,384 KB
testcase_03 AC 23 ms
4,380 KB
testcase_04 AC 227 ms
4,380 KB
testcase_05 AC 608 ms
4,384 KB
testcase_06 AC 38 ms
4,384 KB
testcase_07 AC 213 ms
4,380 KB
testcase_08 AC 928 ms
4,380 KB
testcase_09 AC 6 ms
4,384 KB
testcase_10 AC 30 ms
4,380 KB
testcase_11 AC 21 ms
4,384 KB
testcase_12 AC 90 ms
4,380 KB
testcase_13 AC 38 ms
4,384 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1,795 ms
4,380 KB
testcase_16 AC 66 ms
4,380 KB
testcase_17 AC 276 ms
4,380 KB
testcase_18 AC 5 ms
4,384 KB
testcase_19 AC 148 ms
4,380 KB
testcase_20 AC 38 ms
4,384 KB
testcase_21 AC 21 ms
4,384 KB
testcase_22 AC 12 ms
4,384 KB
testcase_23 AC 1,227 ms
4,384 KB
testcase_24 AC 1 ms
4,384 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 < 25000; 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