Codeforces A. Double Cola 题解

题目很奇怪,就是5个人排队喝可乐,喝完之后编程两个人,然后拍在队后面,然后继续喝可乐。

给出个数值,代表第几罐可乐,问会是第几个人喝到?

http://codeforces.com/problemset/problem/82/A

一个数学问题,仔细点就好了。

要熟练的知识点:

1 要熟悉解决这种递增数列,如何减去循环部分

2 要知道如何计算,求余取答案

#include <string>
#include <iostream>
using namespace std;

void DoubleCola()
{
	string strs[] = {"Sheldon", "Leonard", "Penny", "Rajesh", "Howard"};
	int n = 0;
	cin>>n;

	int i = 1;
	while (n > i*5)//100 - 5 - 10 - 20 - 40 ...
	{
		n -= i*5;
		i <<= 1;
	}
	int a = n / i;
	if (n % i) a++;
	cout<<strs[a-1];
}
时间: 2024-10-21 17:35:46

Codeforces A. Double Cola 题解的相关文章

codeforces A. Supercentral Point 题解

One day Vasya painted a Cartesian coordinate system on a piece of paper and marked some set of points(x1,?y1),?(x2,?y2),?...,?(xn,?yn). Let's define neighbors for some fixed point from the given set (x,?y): point (x',?y') is (x,?y)'s right neighbor,

codeforces New Year Present 题解

The New Year is coming! That's why many people today are busy preparing New Year presents. Vasily the Programmer is no exception. Vasily knows that the best present is (no, it's not a contest) money. He's put n empty wallets from left to right in a r

codeforces Sereja and Dima 题解

Sereja and Dima play a game. The rules of the game are very simple. The players have n cards in a row. Each card contains a number, all numbers on the cards are distinct. The players take turns, Sereja moves first. During his turn a player can take o

codeforces D. Ice Sculptures 题解

The Berland University is preparing to celebrate the 256-th anniversary of its founding! A specially appointed Vice Rector for the celebration prepares to decorate the campus. In the center of the campus n ice sculptures were erected. The sculptures

B - Double Cola

Problem description Sheldon, Leonard, Penny, Rajesh and Howard are in the queue for a "Double Cola" drink vending machine; there are no other people in the queue. The first one in the queue (Sheldon) buys a can, drinks it and doubles! The result

Educational Codeforces Round 64部分题解

Educational Codeforces Round 64部分题解 A 题目大意:给定三角形(高等于低的等腰),正方形,圆,在满足其高,边长,半径最大(保证在上一个图形的内部)的前提下. 判断交点个数是否有限,如果有限,输出. 很明显当正方形套三角形或者三角形套正方形是交点个数是无限的(因为有一条边相交) 其他图形的嵌套交点个数比较好判断,不多赘述 但是注意坑点: 当按照矩形,园,三角这样的顺序是,三角与圆的一个交点是与圆和正方形的交点重合的,判一下就好了 #include<cstdio>

Codeforces 7E - Defining Macros 题解

目录 Codeforces 7E - Defining Macros 题解 前言 做法 程序 结尾 Codeforces 7E - Defining Macros 题解 前言 开始使用博客园了,很想写点东西.(逃 这是一道Codeforces题目. 做法 一道大模拟 相信大家都看得懂题目意思,我就不赘述了. 首先我们读进来\(n\)行,对于每一行,我们把它初步分成一下四块内容: #号 define 宏的名字 宏的表达式 注意:#和define中间可能会有空格,define和宏的名字,宏的名字和宏

Codeforces #Round 376 部分题解

A: 题目传送门:http://codeforces.com/problemset/problem/731/A 直接根据题意模拟即可 1 #include "bits/stdc++.h" 2 3 using namespace std ; 4 typedef long long QAQ ; 5 6 char s[ 1010 ] ; 7 8 inline int Calc ( const char x , const char y ) { 9 if ( x > y ) return

【codeforces】【比赛题解】#849 CF Round #431 (Div.2)

cf的比赛越来越有难度了--至少我做起来是这样. 先看看题目吧:点我. 这次比赛是北京时间21:35开始的,算是比较良心. [A]奇数与结束 "奇数从哪里开始,又在哪里结束?梦想从何处起航,它们又是否会破灭呢?" 给定一个长度为n的序列.确定能不能将序列分成奇数个长度为奇数的非空字串,而且这其中每个子串以奇数开头,以奇数结尾.可以只分成一个(1也是奇数). 输入 第一行一个正整数n,表示序列长度. 第二行n个整数,表示序列中的元素. 输出 输出"Yes"或"