3 条题解
-
13
#include <bits/stdc++.h> using namespace std; const int N = 100010, mod = 5000011; int f[N]; int main() { int n, k, x = 0, tmp = 1; cin >> n >> k; f[0] = 1; for (int i = 1; i <= n; i += 1) { (f[i] += tmp) %= mod; if (i - k > 0) { (tmp += f[i - k]) %= mod; } } for (int i = 0; i <= n; i += 1) { (x += f[i]) %= mod; } cout << x << endl; return 0; }
-
1
代码
# include <bits/stdc++.h> using namespace std ; const int N = 100010 , mod = 5000011 ; int f [ N ] ; int main ( ) { int n , k , x = 0 , tmp = 1 ; cin >> n >> k ; f [ 0 ] = 1 ; for ( int i = 1 ; i <= n ; i += 1 ) { ( f [ i ] += tmp ) %= mod ; if ( i - k > 0 ) { ( tmp += f [ i - k ] ) %= mod ; } } for ( int i = 0 ; i <= n ; i += 1 ) { ( x += f [ i ] ) %= mod ; } cout << x << endl ; return 0 ; }
- 1
信息
- ID
- 1908
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 2
- 标签
- 递交数
- 127
- 已通过
- 80
- 上传者