結果

問題 No.1049 Zero (Exhaust)
ユーザー MiKo_IZUMIMiKo_IZUMI
提出日時 2020-05-08 22:55:37
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 651 bytes
コンパイル時間 311 ms
コンパイル使用メモリ 30,104 KB
実行使用メモリ 17,552 KB
最終ジャッジ日時 2023-09-17 03:20:36
合計ジャッジ時間 1,337 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 9 ms
12,360 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 8 ms
10,500 KB
testcase_06 AC 13 ms
17,548 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 6 ms
6,396 KB
testcase_09 AC 10 ms
13,512 KB
testcase_10 AC 9 ms
14,600 KB
testcase_11 AC 10 ms
14,612 KB
testcase_12 AC 12 ms
16,508 KB
testcase_13 AC 4 ms
5,104 KB
testcase_14 AC 7 ms
8,496 KB
testcase_15 AC 9 ms
12,600 KB
testcase_16 AC 8 ms
10,564 KB
testcase_17 AC 7 ms
10,996 KB
testcase_18 AC 11 ms
14,936 KB
testcase_19 AC 9 ms
12,788 KB
testcase_20 AC 5 ms
6,404 KB
testcase_21 AC 9 ms
13,080 KB
testcase_22 AC 5 ms
8,124 KB
testcase_23 AC 12 ms
17,488 KB
testcase_24 AC 11 ms
17,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long ll;

int main()
{

    int p,k;
    scanf("%d %d",&p,&k);

    if(k==1)
    {
        printf("%d\n",p+1);
    }
    else
    {
    

    ll zero[k],nonzero[k];

    zero[0]=p+1;
    nonzero[0]=p-1;

    for(int i=1;i<k-1;i++)
    {
        zero[i]=(zero[i-1]*(p+1))+(nonzero[i-1]*2);
        nonzero[i]=(zero[i-1]*(p-1))+(nonzero[i-1]*(2*p-2));
        zero[i]=zero[i]%1000000007;
        nonzero[i]=nonzero[i]%1000000007;
    }

    ll ans;
    ans=(zero[k-2]*(p+1))+(nonzero[k-2]*2);
    ans=ans%1000000007;

    printf("%lld\n",ans);

    }

    return 0;
}
0