乱七八糟的杂题。。
Fox Ciel and her friends are in a dancing room. There are n boys and m girls here, and they never danced before. There will be some songs, during each song, there must be exactly one boy and one girl are dancing. Besides, there is a special rule:
- either the boy in the dancing pair must dance for the first time (so, he didn't dance with anyone before);
- or the girl in the dancing pair must dance for the first time.
Help Fox Ciel to make a schedule that they can dance as many songs as possible.
The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of boys and girls in the dancing room.
In the first line print k — the number of songs during which they can dance. Then in the following k lines, print the indexes of boys and girls dancing during songs chronologically. You can assume that the boys are indexed from 1 to n, and the girls are indexed from 1 to m.
2 1
2 1 1 2 1
2 2
3 1 1 1 2 2 2
In test case 1, there are 2 boys and 1 girl. We can have 2 dances: the 1st boy and 1st girl (during the first song), the 2nd boy and 1st girl (during the second song).
And in test case 2, we have 2 boys with 2 girls, the answer is 3.
int q, w;
int main()
{
while( ~scanf("%d%d", &q, &w) ) {
int ans = 2 * min( q, w ) - 1 + max( q, w ) - min( q, w );
printf("%d\n", ans);
int i = 1, j = 1;
for( ; i <= min(q, w); ) {
printf("%d %d\n", i, j);
if( (i+j) % 2 == 0 )
i++;
else
j++;
}
if( q > w ) {
for( i = w+1; i <= q; ++i ) {
printf("%d %d\n", i, w);
}
}
else {
for( i = q+1; i <= w; ++i ) {
printf("%d %d\n", q, i);
}
}
}
return 0;
}
Fox Ciel has some flowers: r red flowers, g green flowers and b blue flowers. She wants to use these flowers to make several bouquets. There are 4 types of bouquets:
- To make a "red bouquet", it needs 3 red flowers.
- To make a "green bouquet", it needs 3 green flowers.
- To make a "blue bouquet", it needs 3 blue flowers.
- To make a "mixing bouquet", it needs 1 red, 1 green and 1 blue flower.
Help Fox Ciel to find the maximal number of bouquets she can make.
The first line contains three integers r, g and b (0 ≤ r, g, b ≤ 109) — the number of red, green and blue flowers.
Print the maximal number of bouquets Fox Ciel can make.
3 6 9
6
4 4 4
4
0 0 0
0
In test case 1, we can make 1 red bouquet, 2 green bouquets and 3 blue bouquets.
In test case 2, we can make 1 red, 1 green, 1 blue and 1 mixing bouquet.
int r, g, b;
int main()
{
while( ~scanf("%d%d%d", &r, &g, &b ) ) {
int ans = r / 3 + g / 3 + b / 3;
int rr = r, gg = g, bb = b;
r %= 3, g %= 3, b %= 3;
int minn = min ( r, min( g, b ) );
int maxx = max ( r, max( g, b ) );
if( minn )
ans += minn;
else {
if( maxx == minn )
ans += maxx;
else if( maxx == 2 && minn == 0 ) {
if( (r == g && r == 2 || r == b && r == 2 || g == b && g == 2) && ans && min( rr, min( gg, bb )) )
ans++;
}
}
printf("%d\n", ans);
}
return 0;
}
表示我来过~ ~