USACO月赛2005 january volume】的更多相关文章

2013-09-18 08:12 由题可知,ans=∑i  ∑j(x[i]-x[j]) 最后整理完之后应该是不同系数的X[i]相加,所以这道题就成了求不同x[i]的系数 对于X[i],它需要减前面(i-1)个不同的数,所以系数先是(i-1),而计算它前 面的每个数时都需要被X[i]减,所以系数成了2*(i-1),而且X[i]会被后面(n-i) 个数减,且计算后面的x时,都会减x[i],所以需要减2*(n-i)所以系数就变成了 2*(2*i-n-1),累加每个即可 //By BLADEVIL va…
2013-09-18 08:23 打表找规律 w[i]:=w[i-1];  奇 w[i]:=w[i-1]+w[i div 2];     偶 //By BLADEVIL var w :..] of longint; i :longint; n :longint; begin assign(input,'sumset.in'); reset(input); assign(output,'sumset.out'); rewrite(output); read(n); w[]:=; to n do =…
2013-09-18 08:13 //By BLADEVIL var n, m :longint; pre, other :..] of longint; last :..] of longint; flag :..] of boolean; tot :longint; ans :..] of longint; i :longint; l :longint; procedure connect(x,y:longint); begin inc(l); pre[l]:=last[x]; last[x…
Description Bessie's been appointed the new watch-cow for the farm. Every night, it's her job to walk across the farm and make sure that no evildoers are doing any evil. She begins at the barn, makes her patrol, and then returns to the barn when she'…
终于找到了usaco月赛的数据…… 根据月赛的名称,我们可以写出数据地址.比如08年一月的月赛即是:http://contest.usaco.org/JAN08  这里要注意区分大小写.…
题目 题目链接,我只在poj上找到了题目,usaco居然上不去. 大意就是说有一些\(1\times 1\times 1\)的小方块堆在一起,问最多能装多少水. 我们在一次测试中出了这题,由于我写水题的能力太弱,挂掉了. 算法1 这是我当时想到的方法. 我们可以统计出每一层能装多少水.由于层数达到了\(10^9\),所以需要离散化一下. 我们可以用并查集来维护装水的面积. 时间复杂度:\(O(n^2 \alpha (n^2))\). 算法2 这是<算法艺术>\(P89\)上的例题(同时也是PO…
T1:跳舞的奶牛 大致题意:一个体积为k的舞台能够同时容纳k只奶牛一起跳舞,他们每头奶牛的跳舞时间不同,如果有一只奶牛跳完了第k+1头奶牛就会立刻上场跳舞,当所有奶牛跳完舞以后我们认为这次表演结束.现在给出奶牛个数,最多用时,每头奶牛的跳舞时间.求舞台最小为多大. 思路:本来写了个程序以为这道题很简单,刚开始排一下序然后就行了,结果交了以后发现只过了五组,然后才发现这道题不能改变顺序(所以说为什么我改变顺序了还是能过五组,usaco的数据也好水......),所以说我想到了堆,然后就用堆写了一下…
题目描述 农场上有N(1 <= N <= 50,000)堆草,放在不同的地点上.FJ有一辆拖拉机,也在农场上.拖拉机和草堆都表示为二维平面上的整数坐标,坐标值在1..1000的范围内.拖拉机的初始位置与所有草堆不同. FJ开拖拉机时,只能平行于坐标轴(即东.南.西.北四个方向),而且每次开动的一段必须是整数长度.例如,他可以向北开2个单位长度,然后向东开3个单位长度.拖拉机不能开到草堆的位置. 请帮助FJ计算出最少要移动多少个草堆,他才能将拖拉机开回坐标原点. 拖拉机可以开到1..1000之外…
以前做过这套题目 这个题又重新写了:http://www.cnblogs.com/jh818012/archive/2013/05/05/3182681.html 还是以前的思路 一直错在一个地方:决策的时候,如果没有走过,直接更新,如果走过,总是选最小值.如果走的是小于mid值的边,那么用tmp = max(dp[x][u] , e[i].val) 更新. 代码比以前好多了好像. #define maxn 1005 int dp[maxn][maxn]; int n,m,k; struct n…
[原题] 1600: [Usaco2008 Oct]建造栅栏 Time Limit: 5 Sec  Memory Limit: 64 MB Submit: 785  Solved: 443 [Submit][Status] Description 勤奋的Farmer John想要建造一个四面的栅栏来关住牛们.他有一块长为n(4<=n<=2500)的木板,他想把这块本板切成4块. 这四块小木板可以是不论什么一个长度仅仅要Farmer John可以把它们围成一个合理的四边形.他可以切出多少种不同的…
上午在打usaco月赛的铜组题,T1T2是用来秒杀的,然而T3卡了一上午,下面给出题面: 题意大概就是输入一个N*N的矩阵,矩阵中元素只有0与1两种状态,每次操作以左上角的点为矩阵中某一矩阵的左上方顶点,将该矩阵中所有元素状态改变(即0变为1,1变为0),求将矩阵中元素全部变为0的最小次数. 第一次看到样例的时候以为就是一道的DFS或BFS的搜索题,然后果断写了DFS,很正常就WA了.然而其实这道题需要用到贪心... 题目中提到,一个矩阵被改变两次之后还是原先的状态,那既然这样,如果将右下角的点…
Sumsets Time Limit: 2000MS   Memory Limit: 200000K Total Submissions: 11892   Accepted: 4782 Description Farmer John commanded his cows to search for different sets of numbers that sum to a given number. The cows use only numbers that are an integer…
Watchcow Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 7512   Accepted: 3290   Special Judge Description Bessie's been appointed the new watch-cow for the farm. Every night, it's her job to walk across the farm and make sure that no ev…
Muddy Fields Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8881   Accepted: 3300 Description Rain has pummeled the cows' field, a rectangular grid of R rows and C columns (1 <= R <= 50, 1 <= C <= 50). While good for the grass, t…
Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10149   Accepted: 3783 Description Rain has pummeled the cows' field, a rectangular grid of R rows and C columns (1 <= R <= 50, 1 <= C <= 50). While good for the grass, the rain make…
Muddy Fields Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7557   Accepted: 2791 Description Rain has pummeled the cows' field, a rectangular grid of R rows and C columns (1 <= R <= 50, 1 <= C <= 50). While good for the grass, t…
http://poj.org/problem?id=2226 Muddy Fields Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7078   Accepted: 2622 Description Rain has pummeled the cows' field, a rectangular grid of R rows and C columns (1 <= R <= 50, 1 <= C <= 5…
主题链接: http://poj.org/problem? id=2230 Watchcow Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 6055   Accepted: 2610   Special Judge Description Bessie's been appointed the new watch-cow for the farm. Every night, it's her job to walk ac…
描述 http://poj.org/problem?id=2229 将一个数n分解为2的幂之和共有几种分法? Sumsets Time Limit: 2000MS   Memory Limit: 200000K Total Submissions: 16207   Accepted: 6405 Description Farmer John commanded his cows to search for different sets of numbers that sum to a given…
  Description Rain has pummeled the cows' field, a rectangular grid of R rows and C columns (1 <= R <= 50, 1 <= C <= 50). While good for the grass, the rain makes some patches of bare earth quite muddy. The cows, being meticulous grazers, don'…
Description Farmer John commanded his cows to search . Here are the possible sets of numbers that sum to : ) ++++++ ) +++++ ) ++++ ) +++ ) +++ ) ++ Help FJ count all possible representations <= N <= ,,). Input A single line with a single integer, N.…
Sumsets Time Limit: 2000MS   Memory Limit: 200000K Total Submissions: 13210   Accepted: 5300 Description Farmer John commanded his cows to search for different sets of numbers that sum to a given number. The cows use only numbers that are an integer…
POJ2279 Mr. Young's Picture Permutations 题意 Language:Default Mr. Young's Picture Permutations Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2513 Accepted: 960 Description Mr. Young wishes to take a picture of his class. The students will…
Naptime Time Limit: 1000MS   Memory Limit: 65536K Total Submissions:3374   Accepted: 1281 Description Goneril is a very sleep-deprived cow. Her day is partitioned into N (3 <= N <= 3,830) equal time periods but she can spend only B (2 <= B < N…
Sumsets Time Limit: 2000MS   Memory Limit: 200000K Total Submissions: 19024   Accepted: 7431 Description Farmer John commanded his cows to search for different sets of numbers that sum to a given number. The cows use only numbers that are an integer…
The Wedding Juicer Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 3440   Accepted: 1551 Description Farmer John's cows have taken a side job designing interesting punch-bowl designs. The designs are created as follows: * A flat board of…
Sumsets Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3968    Accepted Submission(s): 1578 Problem Description Farmer John commanded his cows to search for different sets of numbers that sum t…
Watchcow Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 5258   Accepted: 2206   Special Judge Description Bessie's been appointed the new watch-cow for the farm. Every night, it's her job to walk across the farm and make sure that no ev…
Sumsets Description Farmer John commanded his cows to search for different sets of numbers that sum to a given number. The cows use only numbers that are an integer power of 2. Here are the possible sets of numbers that sum to 7: 1) 1+1+1+1+1+1+1 2)…
Sumsets Time Limit: 2000MS   Memory Limit: 200000K Total Submissions: 20315   Accepted: 7930 Description Farmer John commanded his cows to search for different sets of numbers that sum to a given number. The cows use only numbers that are an integer…