2021/10/14程式培力刷題記錄

这篇博客记录了四道不同的编程竞赛题目,包括CodeForces上的50A、1030A、231A和703A问题。主要涉及计算、条件判断和团队组建等算法应用,通过实例解析了如何解决这些问题,适合编程初学者和竞赛爱好者提升算法能力。
摘要由CSDN通过智能技术生成

刷題記錄

 

ACodeForces 50ADomino piling
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n=0;
    int m=0;
    scanf("%d%d",&n,&m);
    printf("%d",n*m/2);

    return 0;


}

 

BCodeForces 1030AIn Search of an Easy Problem
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    int n=0;
    int counter=0;
    int ans;
    int easy=0;
    int hard=0;
    cin>>n;
    while(counter<n)
    { 
        cin>>ans;
        counter++;
        if(ans==1)
        {
          hard=hard+1;
        }
        else
        {
            easy=easy+1;
        }

    }
    if(hard>0)
    {
        printf("HARD");
    }
        else
        {
            printf("EASY");
        }

    return 0;


}

 

CCodeForces 231ATeam
#include<iostream>
#include<cstdio>

using namespace std;
int main()
{
	int n ;
	int counter = 0;
	int p;
	int v;
	int t;
	int yes = 0;
	cin >> n;
	while (counter < n)
	{
		cin >> p >> v >> t;
		counter++;
		if (p + v + t >= 2)
		{
			yes++;
		}
	}
	cout<<yes;
	return 0;




}

 

DCodeForces 703AMishka and Game
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int rounds = 0;
	int m, c;
	int mwin = 0;
	int cwin = 0;
	cin >> rounds;
	for (int i=0; i < rounds; i++)
	{
		cin >> m >> c;
		if (m > c)
		{
			mwin++;
		}
		else if (c > m)
		{
			cwin++;
		}
	}
	if (mwin > cwin)
	{
		printf("Mishka");
	}
	else if (cwin > mwin)
	{
		printf("Chris");
	}
	else 
	{
		printf("Friendship is magic!^^");
	}
	return 0;
}

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值