
usaco
文章平均质量分 77
topc0o0der
这个作者很懒,什么都没留下…
展开
-
usaco题目分类
1:动态规划: 1. 背包问题: 2.2.2 Subset Sums 2.3.4 Money System 3.1.2 Score Inflation 3.1.6 Stamps 3.4.4 Raucous Rockers 4.1.1 Beef McNuggets 5.3.1 Milk Measuring 2. 最长不XX子序列: 4.3.1 Buy Low Buy Lower 3. 其他 1.5.转载 2010-04-29 19:04:00 · 1481 阅读 · 0 评论 -
usaco——fractions to Decimals
Fractions to DecimalsWrite a program that will accept a fraction of the form N/D, where N is the numerator and D is the denominator and print the decimal representation. If the decimal representatio原创 2010-03-14 14:21:00 · 693 阅读 · 0 评论 -
usaco_cow tours
Cow ToursFarmer John has a number of pastures on his farm. Cow paths connect some pastures with certain other pastures, forming a field. But, at the present time, you can find at least two pastures原创 2010-03-13 22:14:00 · 617 阅读 · 0 评论 -
usaco_ttwo
The Tamworth TwoBIO 98 - Richard ForsterA pair of cows is loose somewhere in the forest. Farmer John is lending his expertise to their capture. Your task is to model their behavior. The chase tak原创 2010-02-24 22:13:00 · 1382 阅读 · 2 评论 -
usaco_money
Money SystemsThe cows have not only created their own government but they have chosen to create their own money system. In their own rebellious way, they are curious about values of coinage. Traditi转载 2010-02-24 15:14:00 · 473 阅读 · 0 评论 -
usaco_zerosum
Zero SumConsider the sequence of digits from 1 through N (where N=9) in increasing order: 1 2 3 ... N. Now insert either a `+ for addition or a `- for subtraction or a ` [blank] to run the dig原创 2010-02-23 20:48:00 · 443 阅读 · 0 评论 -
usaco 教程2
拓扑排序给你一些物品的集合,然后给你一些这些物品的摆放顺序的约束,如"物品A应摆放在物品B前",请给出一个这些物品的摆放方案,使得所有约束都可以得到满足。算法:对于给定的物品创建一个有向图,A到B的弧表示"物品A应摆放在物品B前”。以任意顺序对每个物品进行遍历。每当你找到一个物品,他的入度为0,那么贪心地将它放到当前序列的末尾,删除它所有的出弧,然后对它的出弧指向的所有结点进行递归,用同样的算法。转载 2010-02-23 15:05:00 · 798 阅读 · 0 评论 -
usaco_nocows
效率不高,最长的到了0.6s,中间有个地方可以优化,原理和dp一样,都是过程不记。保存结果。Cow PedigreesSilviu Ganceanu -- 2003 Farmer John is considering purchasing a new herd of cows. In this new herd, each mother cow gives birth to tw原创 2010-02-23 14:47:00 · 558 阅读 · 0 评论 -
usaco_prefix
Longest PrefixIOI96The structure of some biological objects is represented by the sequence of their constituents denoted by uppercase letters. Biologists are interested in decomposing a long seq转载 2010-02-23 14:45:00 · 542 阅读 · 0 评论 -
usaco——holstein
不知怎么的,递归函数让我头大,总是不习惯这种思维。最后千辛万苦把错误找到了。看了看效率,比官方的逊色一点儿。读了一下,都是递归。但是搜索方案不一样。我的先是按总饲料数递增来搜。官方的没有这个顺序。他就是原始搜索,从第一饲料,然后加第二饲料。。。。。。,每加入新饲料都检验,存下当前最好的。中间有剪枝。我想这两种方法的好坏很大程度上决定于具体的数据。效率分析上,就是有的我快,有的他快,当然他快的多一点原创 2010-02-18 11:53:00 · 502 阅读 · 0 评论 -
usaco——milk3
Mothers MilkFarmer John has three milking buckets of capacity A, B, and C liters. Each of the numbers A, B, and C is an integer from 1 through 20, inclusive. Initially, buckets A and B are empty wh转载 2010-02-16 14:11:00 · 637 阅读 · 0 评论 -
usaco——hamming
Hamming CodesRob KolstadGiven N, B, and D: Find a set of N codewords (1 0x554 = 0101 0101 0100 0x234 = 0010 0011 0100Bit differences: xxx xxSince five bits were different,原创 2010-02-18 13:35:00 · 436 阅读 · 0 评论 -
usaco_comehome
Bessie Come HomeKolstad & BurchIts dinner time, and the cows are out in their separate pastures. Farmer John rings the bell so they will start walking to the barn. Your job is to figure out which o原创 2010-03-13 23:52:00 · 446 阅读 · 0 评论 -
usaco_agri_net
Agri-NetRuss CoxFarmer John has been elected mayor of his town! One of his campaign promises was to bring internet connectivity to all farms in the area. He needs your help, of course. Farmer John原创 2010-03-17 07:14:00 · 366 阅读 · 0 评论 -
usaco spin
#include #include const int MOD = 360;const int SIZE = 5;const int LEN = 5;int test[MOD];int para[SIZE][LEN][2];int cnt[SIZE];int v[SIZE];void init();int work();bool check();in转载 2010-04-10 01:32:00 · 411 阅读 · 0 评论 -
ratio
/*LANG: C++ID: yinguan1PROG: ratios*/#include using namespace std;int ratio[3][4];int x,y,z;ifstream fin("ratios.in");ofstream fout("ratios.out");bool Notnone(int j){原创 2010-04-10 11:16:00 · 458 阅读 · 0 评论 -
usaco fact
USER: yin guangxue [yinguan1]TASK: fact4LANG: C++Compiling...Compile: OKExecuting... Test 1: TEST OK [0.000 secs, 2928 KB] Test 2: TEST OK [0.000 secs, 2928 KB] Test 3: TEST OK [0.022 secs, 2928原创 2010-04-09 01:30:00 · 815 阅读 · 1 评论 -
fence
/*ID: yinguan1PROG: fenceLANG: C++*/#include #include using namespace std;const long N=500;//顶点以1-500编号 long G[510][510];//记录两个顶点之间边的条数long con[510];//每个点的度 long cir[1100];lo原创 2010-04-13 08:16:00 · 439 阅读 · 0 评论 -
shopping
/*ID: yinguan1PROG: shoppingLANG: C++*/#include using namespace std;ifstream fin("shopping.in");ofstream fout("shopping.out");int offers;int doffer[105][500];int offerp[100];原创 2010-04-13 08:17:00 · 439 阅读 · 0 评论 -
sweet buffer
#include#define INF 1<<30 //定义无穷const int MAXP=808,MAXN=508;//最大农场数目int cows[MAXN];//牛所在牧场int numOfCow[MAXN];//牧场牛的数量int minLength[MAXP][MAXP];//两牧场之间的最小路径长度bool isInQue[MAXP];//检查是否已进队列原创 2010-04-13 08:14:00 · 398 阅读 · 0 评论 -
magic square
/* ID: yinguan1 TASK: msquareLANG: C++ */ #include using namespace std; #define _max_state_ 40320 #define _vis_mask_ 0x char vis[1<<21] ; int source, target, queue[_转载 2010-04-13 08:12:00 · 501 阅读 · 0 评论 -
stringsobits
/* ID: yinguan1 PROG: kimbits LANG: C++ */ #include using namespace std;unsigned int per(int a,int b){ unsigned int r=1; for(int i=0; i<b; ++i) { r*=(a-i); r/=i+1原创 2010-04-09 11:21:00 · 505 阅读 · 0 评论 -
usaco_shaping regions
这是到现在最让我烦恼的一题了: 不说了,贴一下别人的代码: #include int curr_color, n, s[1001] = {}, x1[1000], y1[1000], x2[1000], y2[1000], color[1000];void Cut(int k, int a, int b, int c, int d){ while (k转载 2010-03-21 11:01:00 · 458 阅读 · 0 评论 -
usaco_score inflation
Score InflationThe more points students score in our contests, the happier we here at the USACO are. We try to design our contests so that people can score as many points as possible, and would like原创 2010-03-17 17:38:00 · 405 阅读 · 0 评论 -
usaco_humble numbers
/*ID: yinguan1PROG: humbleLANG: C++*/#include #include using namespace std;#define MAX 100;#define MAX_th 100000;int N;int nth;int prime[100];int start[100];int resul原创 2010-03-19 11:17:00 · 483 阅读 · 0 评论 -
usaco——frac1
Ordered FractionsConsider the set of all reduced fractions between 0 and 1 inclusive with denominators less than or equal to N. Here is the set when N = 5: 0/1 1/5 1/4 1/3 2/5 1/2 3/5 2/3 3/4 4/转载 2010-02-17 11:41:00 · 518 阅读 · 0 评论 -
usaco——checker
Checker ChallengeExamine the 6x6 checkerboard below and note that the six checkers are arranged on the board so that one and only one is placed in each row and each column, and there is never more t原创 2010-02-16 14:24:00 · 561 阅读 · 0 评论 -
usaco——sprime
Superprime RibButchering Farmer Johns cows always yields the best prime rib. You can tell prime ribs by looking at the digits lovingly stamped across them, one by one, by FJ and the USDA. Farmer Jo原创 2010-02-16 14:23:00 · 1040 阅读 · 0 评论 -
usaco——Friday
Friday the ThirteenthIs Friday the 13th really an unusual event? That is, does the 13th of the month land on a Friday less often than on any other day of the week? To answer this question, writ原创 2010-02-10 21:04:00 · 576 阅读 · 0 评论 -
usaco——ariprog
这道题我一看蛮简单,写了50来行,结果time limit execeeded.后来搜了搜,知道了,是自己把等差写在外面而且是从1开始增。。。要是遇到p》100的话,最大数字是100*100*2=20000; 从1开始看,再在1下找是否存在,差不多有20000*100*100/2就是一亿了。。。,这个的确是太多了。当初这么做也是因为看答案是要求按d来升序排的。要是在生成的双平方数中搜,双平方转载 2010-02-12 13:59:00 · 824 阅读 · 0 评论 -
usaco——crypt1
Prime CryptarithmThe following cryptarithm is a multiplication problem that can be solved by substituting digits from a specified set of N digits into the positions marked with *. If the set of p原创 2010-02-10 21:25:00 · 677 阅读 · 0 评论 -
usaco——palsquare
Palindromic SquaresRob Kolstad Palindromes are numbers that read the same forwards as backwards. The number 12321 is a typical palindrome. Given a number base B (2 Print both the number and i原创 2010-02-10 21:14:00 · 411 阅读 · 0 评论 -
usaco——namenum
Name That NumberAmong the large Wisconsin cattle ranchers, it is customary to brand cows with serial numbers to please the Accounting Department. The cow hands dont appreciate the advantage of t原创 2010-02-10 21:12:00 · 810 阅读 · 0 评论 -
usaco——transform
TransformationsA square pattern of size N x N (1 #1: 90 Degree Rotation: The pattern was rotated clockwise 90 degrees. #2: 180 Degree Rotation: The pattern was rotated clockwise 180 degrees原创 2010-02-10 21:10:00 · 574 阅读 · 0 评论 -
usaco——beads
Broken NecklaceYou have a necklace of N red, white, or blue beads (3 1 2 1 2 r b b r b r r b r原创 2010-02-10 21:06:00 · 530 阅读 · 0 评论 -
usaco日记——ride
近几天开始做usaco,希望在此记录一下。同时也希望有人能对我的代码提点儿建议(但愿吧。。。); Your Ride Is HereIt is a well-known fact that behind every good comet is a UFO. These UFOs often come to collect loyal supporters from here on原创 2010-02-10 20:24:00 · 359 阅读 · 0 评论 -
usaco——packrec
图片上传不行了,有六种情况,可以去网上搜。。。这次代码是别人的。。。不是我不想写,是我写了,忘存了,而且这道题蛮难的,之前看了别人的思路,写了,但是到枚举时,就是列举4*3*2*1=24和2*2*2=8时觉得巨麻烦,看了网上有用for一层一层套的,有的自己列举的(汗),这个代码在这点上蛮有深度的,用的是递归函数,在2*2*2时用了位操作,超帅!但是我觉得在判断第6种情况是这段代码是有漏洞的原创 2010-02-10 21:26:00 · 837 阅读 · 0 评论 -
usaco——dualpal
Dual PalindromesMario Cruz (Colombia) & Hugo Rickeboer (Argentina)A number that reads the same from right to left as when read from left to right is called a palindrome. The number 12321 is a pal原创 2010-02-10 21:15:00 · 417 阅读 · 0 评论 -
usaco——milk2
Milking CowsThree farmers rise at 5 am each morning and head for the barn to milk three cows. The first farmer begins milking his cow at time 300 (measured in seconds after 5 am) and ends at time 10原创 2010-02-10 21:08:00 · 710 阅读 · 0 评论 -
usaco——milk
Mixing MilkSince milk packaging is such a low margin business, it is important to keep the price of the raw product (milk) as low as possible. Help Merry Milk Makers get the milk they need in the原创 2010-02-10 21:18:00 · 445 阅读 · 0 评论