CodeForces - 120B

题目地址
**题目:**A team quiz game called “What? Where? When?” is very popular in Berland. The game is centered on two teams competing. They are the team of six Experts versus the team of the Audience. A person from the audience asks a question and the experts are allowed a minute on brainstorming and finding the right answer to the question. All it takes to answer a typical question is general knowledge and common logic. The question sent be the audience are in envelops lain out in a circle on a round table. Each envelop is marked by the name of the asker’s town. Each question is positioned in a separate sector. In the centre of the table is a spinning arrow. Thus, the table rather resembles a roulette table with no ball but with a spinning arrow instead. The host sets off the spinning arrow to choose a question for the experts: when the arrow stops spinning, the question it is pointing at is chosen. If the arrow points at the question that has already been asked, the host chooses the next unanswered question in the clockwise direction. Your task is to determine which will be the number of the next asked question if the arrow points at sector number k.

Input
The first line contains two positive integers n and k (1 ≤ n ≤ 1000 and 1 ≤ k ≤ n) — the numbers of sectors on the table and the number of the sector where the arrow is pointing. The second line contains n numbers: ai = 0 if the question from sector i has already been asked and ai = 1 if the question from sector i hasn’t been asked yet (1 ≤ i ≤ n). The sectors are given in the clockwise order, the first sector follows after the n-th one.

Output
Print the single number — the number of the sector containing the question the experts will be asked. It is guaranteed that the answer exists, that is that not all the questions have already been asked.

Examples
Input
5 5
0 1 0 1 0
Output
2
Input
2 1
1 1
Output
1
**题意:**一个名为“什么?”在哪里?“什么时候?”这句话在伯兰很流行。比赛以两队比赛为中心。他们是由六名专家组成的团队和由观众组成的团队。观众中有一个人提出一个问题,专家们可以有一分钟的时间进行头脑风暴,找到问题的正确答案。回答一个典型的问题只需要常识和一般的逻辑。送出的问题被观众们在信封里围成一圈摊在一张圆桌上。每个信封上都标有提问者所在的城市。每个问题都放在一个单独的部门。在桌子的中央是一个旋转的箭头。因此,这个桌子很像一个轮盘赌桌,没有球,但有一个旋转的箭头。主持人启动旋转箭头,为专家选择一个问题:当箭头停止旋转时,它所指向的问题就被选择了。如果箭头指向已经问过的问题,主人就按顺时针方向选择下一个未回答的问题。你的任务是,如果箭头指向扇区数k,确定下一个问题的个数。
**思路:**判断自己设置的变量和所求变量的关系,之后进行解答。
代码:#include<bits/stdc++.h>
using namespace std;
int main()
{
freopen(“input.txt”,“r”,stdin);
freopen(“output.txt”,“w”,stdout);

int n,k;
scanf("%d%d",&n,&k);
	int i;
	int x[1005];
	for(i=1;i<=n;i++)
		cin>>x[i];
	for(i=k;;)
	{
		if(x[i]==1)
			break;
		if(i>n)
			i=1;
		else
			i++;
	}
	printf("%d\n",i);
return 0;

}
**总结:**熟练运用c++就很简单。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值