0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

競プロ日記#25/04/10

Posted at

アルゴ式-コマの道順

  • dp[][]に対してある(i,j)マスが上からくる場合と左からくる場合で場合分けする
for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
        // 上から来る場合
        if (i - 1 >= 0) dp[i][j] += dp[i-1][j];

        // 左から来る場合
        if (j - 1 >= 0) dp[i][j] += dp[i][j-1];
    }
}
  • ちなみに高校数学でやった(N+N)!をN!とN!の積を割るパターンもあるが実装が面倒

アルゴ式-コマの道順 (壁あり)

for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
        if (S[i][j] == '.'){
            // 上から来る場合
            if (i - 1 >= 0) dp[i][j] += dp[i-1][j];

            // 左から来る場合
            if (j - 1 >= 0) dp[i][j] += dp[i][j-1];
            }
        
    }
}
  • S[i][j]が.か#かで場合分けすれば十分

アルゴ式-500 円玉貯金

  • 簡単
  • iを0からNまでのN+1回for文で回してX + i * increを出力する
int N,X;
cin >> N >> X;
int incre = 500;

for (int i = 0;i <= N;i++){

    cout << X + i * incre << endl;
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?