HDUOJ 1023 Train Problem II
2017-08-13 18:52
169 查看
#ifdef _DEBUG #pragma warning(disable : 4996) #endif #include <iostream> #include <string> #include <vector> #include <stack> #include <queue> #include <deque> #include <set> #include <map> #include <algorithm> #include <functional> #include <sstream> #include <utility> #include <cstring> #include <cstdio> #include <cstdlib> #include <ctime> #include <cmath> #include <cctype> #define CLEAR(a, b) memset(a, b, sizeof(a)) #define CLOSE() ios::sync_with_stdio(false) #define IN() freopen("in.txt", "r", stdin) #define OUT() freopen("out.txt", "w", stdout) #define PF(a) printf("%d\n", a) #define SF(a) scanf("%d", &a) #define SFF(a, b) scanf("%d%d", &a, &b) #define SFFF(a, b, c) scanf("%d%d%d", &a, &b, &c) #define FOR(i, a, b) for(int i = a; i < b; ++i) #define LL long long #define maxn 105 #define maxm 500005 #define MOD 1000000007 #define INF 1e18 using namespace std; //-------------------------CHC------------------------------// //HDUOJ 1023 Train Problem II #define base 100000 #define len 12 void Mult(int *a, int b) { int carry = 0;//从低位到高位 for (int i = len - 1; i >= 0; --i) { carry += a[i] * b; a[i] = carry % base; carry /= base; } } void divi(int *a, int b) { int div = 0;//从高位到低位 FOR(i, 0, len) { div = div*base + a[i]; a[i] = div / b; div %= b; } } int Cat[maxn][len]; void Catalan() { CLEAR(Cat, 0); Cat[1][len - 1] = 1; FOR(i, 2, 101) { memcpy(Cat[i], Cat[i - 1], len*sizeof(int)); Mult(Cat[i], 4 * i - 2); divi(Cat[i], i + 1); } } int main() { Catalan(); int n; while (~SF(n)) { int i = 0; while (Cat [i] == 0) i++; printf("%d", Cat [i++]); FOR(j, i, len) printf("%05d", Cat [j]); puts(""); } return 0; }一不小心错过了晚上的比赛,心态爆炸。。。
这题大数乘法+Catalan数。
相关文章推荐
- HDU 1023 Train Problem II(卡特兰数)
- hdu 1023 Train Problem II 解题报告
- hdu 1023 ——Train Problem II(卡特兰数+高精度+java)
- hdu 1023 Train Problem II 数学catalan数
- HDOJ 1023 Train Problem II
- HDU 1023 Train Problem II
- hdu 1023 Train Problem II(卡特兰数)
- hdu 1023 Train Problem II 高精训练
- hdu 1023 Train Problem II
- HDU 1023 Train Problem II (卡特兰数,经典)
- hdu/hdoj 1023 Train Problem II
- hdoj 1023 Train Problem II 【卡特兰数】
- Train Problem II hdu 1023 卡特兰数 (模板)
- hdu-1023-Train Problem II
- hdu 1023 Train Problem II 高精训练
- 1023 Train Problem II
- hdu 1023 Train Problem II
- HDU-1023 Train Problem II
- hdu 1023 Train Problem II【卡特兰数】
- hdu 1023 Train Problem II(卡特兰数的应用)出栈序列的统计