結果
問題 | No.616 へんなソート |
ユーザー |
![]() |
提出日時 | 2018-08-27 14:21:09 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 79 ms / 2,000 ms |
コード長 | 649 bytes |
コンパイル時間 | 201 ms |
コンパイル使用メモリ | 30,080 KB |
実行使用メモリ | 54,256 KB |
最終ジャッジ日時 | 2024-07-01 04:07:12 |
合計ジャッジ時間 | 1,355 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#include<stdio.h> #include<stdlib.h> typedef unsigned int uint; #define POS(i,j) ((i)*(k+1)+(j)) void run(void){ const uint mod=1000000007; uint n,k; scanf("%d%d",&n,&k); uint *dp=(uint *)calloc((n+1)*(k+1),sizeof(uint)); dp[POS(1,0)]=1; uint i,j; for(i=2;i<=n;i++){ uint local=0; for(j=0;j<=k && j<=i-1;j++){ local=(local+dp[POS(i-1,j)])%mod; dp[POS(i,j)]=local; } for(;j<=k;j++){ local=(local+dp[POS(i-1,j)]-dp[POS(i-1,j-i)]+mod)%mod; dp[POS(i,j)]=local; } } int sum=0; for(i=0;i<=k;i++) sum=(sum+dp[POS(n,i)])%mod; printf("%d\n",sum); } int main(void){ run(); return 0; }