ZOJ 1057 Undercut (格式问题)

本文提供了一道来自浙江大学ACM在线评测系统的编程题(编号1057)的解答思路及完整代码实现。文章强调了审题的重要性,并详细展示了如何根据题目要求正确计算两个玩家得分的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1057

做题的时候一定要看清题意,提交之前一定要再 看一遍样例输出的格式。

就是这样的一句话 

where the value of a and b are for you to determine. A blank line should separate output lines.
有多少人WA了!!!!!

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define inf 999999999
using namespace std;
int a[100],b[100];
int main()
{
    //freopen("2.txt","w",stdout);
    int n,count = 0;
    while(cin>>n && n)
    {
        if(count) cout<<endl;/*输出空行*/
        count++;
        int i,j,scorea = 0, scoreb = 0;
        for(i = 0; i < n; i++)
        cin>>a[i];
        for(i = 0; i < n; i++)
        {
            cin>>b[i];
            if(a[i] + b[i] == 3)
            {
                if(a[i]>b[i]) scoreb += 6;
                else scorea += 6;
            }
            else if(abs(a[i] - b[i]) == 1)
            {
                if(a[i] > b[i]) scoreb += (a[i] + b[i]);
                else
                scorea += (a[i] + b[i]);
            }
            else if(a[i] == b[i]) continue;
            else
            {
                //if(i == 0) cout<<a[i]<<"********"<<b[i]<<endl;
                if(a[i] > b[i]) scorea += a[i];//,cout<<a[i]<<"**"<<scorea + a[i]<<endl;
                else
                scoreb += b[i];
            }
        }

        cout<<"A has "<<scorea<<" points."<<" B has "<<scoreb<<" points."<<endl;
        //cout<<endl;
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值