bzoj1630 [Usaco2007 Demo]Ant Counting】的更多相关文章

bzoj2023[Usaco2005 Nov]Ant Counting 数蚂蚁&&bzoj1630[Usaco2007 Demo]Ant Counting 题意: t个族群,每个族群有ni只蚂蚁,同族群蚂蚁没有区别.问从所有蚂蚁中选出s到b只蚂蚁有多少方案.t≤1000,ni≤100. 题解: dp,f[i][j]表示考虑第i个族群,剩下j只蚂蚁没选择.则f[i][j]=sum(f[i-1][j-k]),k=0..min(j,n[i]).然而O(n^3)会超时,注意到可以计算f[i-1][…
Description Bessie was poking around the ant hill one day watching the ants march to and fro while gathering food. She realized that many of the ants were siblings, indistinguishable from one another. She also realized the sometimes only one ant woul…
[BZOJ1630/2023][Usaco2007 Demo]Ant Counting 题意:T中蚂蚁,一共A只,同种蚂蚁认为是相同的,有一群蚂蚁要出行,个数不少于S,不大于B,求总方案数 题解:DP,先列出朴素的方程,用f[i][j]表示前i种,出行j只的方案数,v[i]代表第i中蚂蚁的个数 f[i][j]=∑f[i-1][j-k] (0≤k≤min(j,v[i])) 也可以表示为 f[i][j]=∑f[i-1][k] (j-min(j,v[i])≤k≤j) 发现时间复杂度为均摊O(A^2),…
传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1630 http://www.lydsy.com/JudgeOnline/problem.php?id=2023 [题解] 直接dp,f[i,j]表示第i个种族选了j只蚂蚁的方案数,转移枚举这个种族选择的方案. 然后可以前缀和+滚动数组 # include <stdio.h> # include <string.h> # include <iostream> # i…
http://www.lydsy.com/JudgeOnline/problem.php?id=1630 题意,给你n种数,数量为m个,求所有的数组成的集合选长度l-r的个数 后两者待会写.. 裸dp其实应该会tle的额,但是数据弱? d[i][j]表示前i种j长度的数量 d[i][j]=sum{d[i-1][j-k]} 1<=k<=a[i] 会爆mle.但是发现这是裸动态数组.. 注意顺序即可 #include <cstdio> #include <cstring>…
满脑子组合数学,根本没想到dp 设f[i][j]为前i只蚂蚁,选出j只的方案数,初始状态为f[0][0]=1 转移为 \[ f[i][j]=\sum_{k=0}^{a[i]}f[i-1][j-k] \] \[ f[i][j]=\sum_{k=max(j-a[i],0)}^{j}f[i-1][k] \] 这样显然时空都不行,用滚动数组优化空间,前缀和优化时间即可 #include<iostream> #include<cstdio> using namespace std; cons…
Ant Counting Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4982   Accepted: 1896 Description Bessie was poking around the ant hill one day watching the ants march to and fro while gathering food. She realized that many of the ants were…
1629: [Usaco2007 Demo]Cow Acrobats Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 601  Solved: 305[Submit][Status] Description Farmer John's N (1 <= N <= 50,000) cows (numbered 1..N) are planning to run away and join the circus. Their hoofed feet pre…
2023: [Usaco2005 Nov]Ant Counting 数蚂蚁 Time Limit: 4 Sec  Memory Limit: 64 MBSubmit: 56  Solved: 16[Submit][Status] Description     有一天,贝茜无聊地坐在蚂蚁洞前看蚂蚁们进进出出地搬运食物.很快贝茜发现有些蚂蚁长得几乎一模一样,于是她认为那些蚂蚁是兄弟,也就是说它们是同一个家族里的成员.她也发现整个蚂蚁群里有时只有一只出来觅食,有时是几只,有时干脆整个蚁群一起出来.这…
1628: [Usaco2007 Demo]City skyline Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 256  Solved: 210[Submit][Status] Description The best part of the day for Farmer John's cows is when the sun sets. They can see the skyline of the distant city. Bessie w…