結果

問題 No.3027 f-列とh-列
ユーザー tnakao0123
提出日時 2025-02-22 23:35:59
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 805 bytes
コンパイル時間 380 ms
コンパイル使用メモリ 41,600 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-02-22 23:36:00
合計ジャッジ時間 1,731 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:30:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   30 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
main.cpp:31:37: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   31 |   for (int i = n; i >= 0; i--) scanf("%d", fs + i);
      |                                ~~~~~^~~~~~~~~~~~~~

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 3027.cc:  No.3027 f-蛻励→h-蛻・- yukicoder
 */

#include<cstdio>
#include<algorithm>

using namespace std;

/* constant */

const int MAX_N = 25;

/* typedef */

using ll = long long;

/* global variables */

int fs[MAX_N + 1];
ll cs[MAX_N + 1][MAX_N + 1], hs[MAX_N + 1];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = n; i >= 0; i--) scanf("%d", fs + i);

  for (int i = 0; i <= n; i++) {
    cs[i][0] = cs[i][i] = 1;
    for (int j = 1; j < i; j++)
      cs[i][j] = cs[i - 1][j - 1] + cs[i - 1][j];
  }

  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= i; j++)
      hs[j] += cs[i][j] * fs[i] * (1 - ((i - j) & 1) * 2);

  for (int i = n; i >= 0; i--)
    printf("%lld%c", hs[i], (i > 0) ? ' ' : '\n');

  return 0;
}
0