我是靠谱客的博主 务实舞蹈,最近开发中收集的这篇文章主要介绍A. Greg's Workout,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Greg is a beginner bodybuilder. Today the gym coach gave him the training plan. All it had was n integers a1, a2, ..., an. These numbers mean that Greg needs to do exactly n exercises today. Besides, Greg should repeat the i-th in order exerciseai times.

Greg now only does three types of exercises: "chest" exercises, "biceps" exercises and "back" exercises. Besides, his training is cyclic, that is, the first exercise he does is a "chest" one, the second one is "biceps", the third one is "back", the fourth one is "chest", the fifth one is "biceps", and so on to the n-th exercise.

Now Greg wonders, which muscle will get the most exercise during his training. We know that the exercise Greg repeats the maximum number of times, trains the corresponding muscle the most. Help Greg, determine which muscle will get the most training.

Input

The first line contains integer n (1 ≤ n ≤ 20). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 25) — the number of times Greg repeats the exercises.

Output

Print word "chest" (without the quotes), if the chest gets the most exercise, "biceps" (without the quotes), if the biceps gets the most exercise and print "back" (without the quotes) if the back gets the most exercise.

It is guaranteed that the input is such that the answer to the problem is unambiguous.

Sample test(s)
input
2
2 8
output
biceps
input
3
5 1 10
output
back
input
7
3 3 2 7 9 6 8
output
chest
Note

In the first sample Greg does 2 chest, 8 biceps and zero back exercises, so the biceps gets the most exercises.

In the second sample Greg does 5 chest, 1 biceps and 10 back exercises, so the back gets the most exercises.

In the third sample Greg does 18 chest, 12 biceps and 8 back exercises, so the chest gets the most exercise.


解题说明:此题就是找到三个值中的最大值

#include <iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;

int main()
{
	int i,n;
	int temp,max;
	int b[3];
	b[0]=0;
	b[1]=0;
	b[2]=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&temp);
		if(i%3==0)
		{
			b[0]+=temp;
		}
		else if(i%3==1)
		{
			b[1]+=temp;
		}
		else
		{
			b[2]+=temp;
		}
	}
	max=b[0];
	temp=0;
	for(i=0;i<3;i++)
	{
		if(b[i]>max)
		{
			max=b[i];
			temp=i;
		}
	}

	if(temp==0)
	{
		printf("chestn");
	}
	else if(temp==1)
	{
		printf("bicepsn");
	}
	else
	{
		printf("backn");
	}
	return 0;
}



最后

以上就是务实舞蹈为你收集整理的A. Greg's Workout的全部内容,希望文章能够帮你解决A. Greg's Workout所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(58)

评论列表共有 0 条评论

立即
投稿
返回
顶部