sgu269:Rooks(dp)
来源:互联网 发布:java线程安全的例子 编辑:程序博客网 时间:2024/06/15 23:01
题目大意:
分析:
AC code:
#include <cstdio>#include <cmath>#include <cstdlib>#include <cstring>#include <cctype>#include <algorithm>#include <string>#include <sstream>#include <iostream>#include <map>#include <set>#include <list>#include <stack>#include <queue>#include <vector>#define pb push_back#define mp make_pairtypedef long long LL;typedef double DB;typedef long double LD;using namespace std;const int MAXN = 259;const int MAXL = 209;const int mod = 10000;int n, k;int a[MAXN];struct BigNum{ int len; int a[MAXL]; BigNum() { len = 1; memset(a, 0, sizeof a); } void init(int x) {a[len = 1] = x;} void shift() { for(int i = 1; i <= len; ++i) { a[i+1] += a[i]/mod; a[i] %= mod; } while(a[len+1]) { len++; a[len+1] += a[len]/mod; a[len] %= mod; } while(!a[len] && len) len--; if(!len) len = 1; } friend BigNum operator + (const BigNum &a, const BigNum &b) { BigNum ret; int maxl = max(a.len, b.len); for(int i = 1; i <= maxl; ++i) ret.a[i] += a.a[i]+b.a[i]; ret.len = maxl; ret.shift(); return ret; } friend BigNum operator * (const BigNum &a, int k) { BigNum ret = a; for(int i = 1; i <= ret.len; ++i) ret.a[i] *= k; ret.shift(); return ret; } void print() { printf("%d", a[len]); for(int i = len-1; i >= 1; --i) printf("%04d", a[i]); }};BigNum f[MAXN];int main(){ #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif scanf("%d%d", &n, &k); for(int i = 1; i <= n; ++i) scanf("%d", a+i); sort(a+1, a+n+1); for(int i = 0; i <= n; ++i) f[0].init(1); for(int i = 1; i <= n; ++i) for(int j = a[i]+1; j >= 1; --j) f[j] = f[j]+f[j-1]*(a[i]-j+1); f[k].print(); #ifndef ONLINE_JUDGE fclose(stdin); fclose(stdout); #endif return 0;}
0 0
- sgu269:Rooks(dp)
- LightOJ 1005 - Rooks(DP)
- LightOj 1005 - Rooks 区间dp
- sgu - 269 - Rooks(大数dp)
- LightOJ 1005 - Rooks (dp、组合数学)
- sgu 222 - Little Rooks 简单的状态压缩DP
- LightOJ 1005 - Rooks (组合数学dp模拟)
- LightOJ 1005 Rooks 动态规划dp || 组合数学
- Fabled Rooks
- A - Rooks
- Fabled Rooks
- Fabled Rooks
- HDU3160 Rooks
- UVA11134_Fabled Rooks
- Fabled Rooks
- A - Rooks
- uva 11134 Fabled Rooks
- Uva-11134-Fabled Rooks
- printf(未提交)
- 【java基础】——集合类(上)
- 我的Java开发学习之旅------>求字符串中出现次数最多的字符串以及出现的次数
- Autolayout使用详细介绍
- 数组及排序
- sgu269:Rooks(dp)
- 字符集个人理解
- php网站密码md5加密串比较方式
- NSString 的内存问题
- 农夫过河问题 简单的搜索
- How to Add a User and Grant Root Privileges on CentOS 6.5
- mongodb 学习笔记 01 -- 概述,安装,运行
- 浅谈OOP
- Hi3518开发板开发总结