USACO 1.1 Broken Necklace 破碎的项链 解题报告
Broken Necklace
You have a necklace of N red, white, or blue beads (3<=N<=350) some of which are red, others blue, and others white, arranged at random. Here are two examples for n=29:
&nb[……]
Broken Necklace
You have a necklace of N red, white, or blue beads (3<=N<=350) some of which are red, others blue, and others white, arranged at random. Here are two examples for n=29:
&nb[……]
Controlling Companies
Some companies are partial owners of other companies because they have acquired part of their total shares of stock. For example, Ford owns 12% of Mazda. It is said that a company A controls company B if at least one of the following co[......]
The Tamworth Two
BIO \'98 - Richard Forster
A 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 takes place on a 10 by 10 planar grid. Squares can be e[......]
Cow Tours
Farmer 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 that cannot be connected by any sequence of cow paths, thus[......]
USACO 2.4 Overfencing 穿越栅栏
Overfencing
Kolstad and Schrijvers
Farmer John went crazy and created a huge maze of fences out in a field. Happily, he left out two fence segments on the edges, and thus created two exits for the maze. Even more happily, the maze[......]
USACO 2.2 Subset Sums集合
For many sets of consecutive integers from 1 through N (1 <= N <= 39), one can partition the set into two sets whose sums are identical.
For example, if N=3, one can partition the set {1, 2, 3} in one way so that the sums of both[……]
Packing Rectangles 铺放矩形块 (IOI 95)
在网上看了挺多解释这一题的文章,总感觉没看大懂,所以自己写一篇文章吧。希望能够帮助大家理解一下这一题。题目如下:
http://www.nocow.cn/index.php/Translate:USACO/packrec
开始拿到题目确实没怎么看懂,网上也有很多人说它是个水题,我倒感觉不以为然,我看了一些网上的人写的代码,说它是水题的人都是怎么写的。整个程序框架就是第一种情况循环+判断,第二种情况循环+判断,…………(以此类推)
接下来我来说下我的[……]
这题很简单,一位一位算就是,唯一要注意的就是mod 11 = 10的时候,要用X。代码:
C语言:
#include <stdio.h>
#include <ctype.h>
char isbn[14];
char getint(void)
{
static int i = 0;
int t;
do{
t = isbn[i++];
}while(!isdigit(t));
return t - \'0\';
}
int main(void)
{
int[......]
不知道这题该属于哪个类别,,贪心?枚举?反正不难,,代码:
C语言:
#include <stdio.h>
int main(void)
{
int i;
int a, b;
int ans = 0, t = 0;
for(i = 1; i <= 7; i++){
scanf(%d%d, &a, &b);
if((a + b > 8) && (a + b > t)){
ans = i;
t = a + b;
}
}
printf([......]