赞
踩
多画画图,有注释。
- // #pragma GCC optimize(2)
- #include <iostream>
- #include <cstdio>
- #include <algorithm>
- #include <queue>
- #include <cmath>
- #include <string>
- #include <vector>
- #include <stack>
- #include <map>
- #include <sstream>
- #include <cstring>
- #include <set>
- #include <cctype>
- #include <bitset>
- #define IO \
- ios::sync_with_stdio(false); \
- // cout.tie(0);
- using namespace std;
- //int dis[8][2] = {0, 1, 1, 0, 0, -1, -1, 0, 1, -1, 1, 1, -1, 1, -1, -1};
- typedef unsigned long long ULL;
- typedef long long LL;
- typedef pair<int, int> P;
- const int maxn = 2e5 + 10;
- const int maxm = 2e5 + 10;
- const LL INF = 0x3f3f3f3f3f3f3f3f;
- const int inf = 0x3f3f3f3f;
- const LL mod = 1e9 + 7;
- const double pi = acos(-1);
- LL dp[2030][1030];
- int main()
- {
- #ifdef WXY
- freopen("in.txt", "r", stdin);
- // freopen("out.txt", "w", stdout);
- #endif
- dp[1][1]=1; // 只有一个位置 放 1
- for(int i=2;i<=2020;i++) // 当前用了 i 个数字
- {
- for(int j=1;j<=i;j++) // 第一行放了 j 个数字
- {
- dp[i][j]+=dp[i-1][j-1]; // 无论如何下一个数字总能放在第一行最右边的位置
- if(j*2>=i) // 如果第二行放的数字比第一行少 那么 第二行还能多一个位置放数字
- dp[i][j]+=dp[i-1][j];
- dp[i][j]%=2020;
- }
- }
- cout<<dp[2020][1010];// 用了前2020个数字,第一行放了1010个数字
- return 0;
- }
-

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。