322A - Ciel and Dancing 322B - Ciel and Flowers

乱七八糟的杂题。。

A. Ciel and Dancing
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of boys and girls in the dancing room.

Output

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.

Sample test(s)
Input
2 1
Output
2
1 1
2 1
Input
2 2
Output
3
1 1
1 2
2 2
Note

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.

题意很明显,给出n男m女跳舞,每次跳的人中必须有一男一女且其中一个是第一次跳。

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;
}

B. Ciel and Flowers
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

Input

The first line contains three integers r, g and b (0 ≤ r, g, b ≤ 109) — the number of red, green and blue flowers.

Output

Print the maximal number of bouquets Fox Ciel can make.

Sample test(s)
Input
3 6 9
Output
6
Input
4 4 4
Output
4
Input
0 0 0
Output
0
Note

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.

题意更果的B

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;
}

表示我来过~ ~


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值