ZOJ 2965 Accurately Say "CocaCola"!
Time Limit: 2 Seconds Memory Limit: 65536 KB
In a party held by CocaCola company, several students stand in a circle and play a game.
One of them is selected as the first, and should say the number 1. Then they continue to count number from 1 one by one (clockwise). The game is interesting in that, once someone counts a number which is a multiple of 7 (e.g. 7, 14, 28, ...) or contains the digit '7' (e.g. 7, 17, 27, ...), he shall say "CocaCola" instead of the number itself.
For example, 4 students play this game. At some time, the first one says 25, then the second should say 26. The third should say "CocaCola" because 27 contains the digit '7'. The fourth one should say "CocaCola" too, because 28 is a multiple of 7. Then the first one says 29, and the game goes on. When someone makes a mistake, the game ends.
During a game, you may hear a consecutive of p "CocaCola"s. So what is the minimum number that can make this situation happen?
For example p = 2, that means there are a consecutive of 2 "CocaCola"s. This situation happens in 27-28 as stated above. 27 is then the minimum number to make this situation happen.
Input
Standard input will contain multiple test cases. The first line of the input is a single integer T (1 <= T <= 100) which is the number of test cases. And it will be followed by T consecutive test cases.
There is only one line for each case. The line contains only one integer p (1 <= p <= 99).
Output
Results should be directed to standard output. The output of each test case should be a single integer in one line, which is the minimum possible number for the first of the p "CocaCola"s stands for.
Sample Input
2
2
3
Sample Output
27
70
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std; int main()
{
int T,p,i,b=/*b如果不赋初值就会段错误*/,j=;
scanf("%d",&T);
int a[];
memset(a, , sizeof(a));
for (i = ; i <= ; i++)
{
if (i % == || i % == || i / == || (i / ) % == )
b++;
else if(b!=)
{
for (; j <= b; j++)
a[j] = i - b;
b = ;
}
}
while (T--)
{
scanf("%d",&p);
printf("%d\n", a[p]);
}
return ;
}
ZOJ 2965 Accurately Say "CocaCola"!的更多相关文章
- ZOJ 2965 Accurately Say "CocaCola"!(预处理)
Accurately Say "CocaCola"! Time Limit: 2 Seconds Memory Limit: 65536 KB In a party he ...
- ZOJ2965 Accurately Say "CocaCola"! 线性扫描
Accurately Say "CocaCola"! 范围找到:1--700左右,然后打表就ok了 #include<cstdio> #include<cstdl ...
- The 5th Zhejiang Provincial Collegiate Programming Contest------ProblemA:Accurately Say "CocaCola"!
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2965 题意:一群人玩过“7”的游戏,有7的数字或者7的倍数就要喊“coca ...
- nenu contest3 The 5th Zhejiang Provincial Collegiate Programming Contest
ZOJ Problem Set - 2965 Accurately Say "CocaCola"! http://acm.zju.edu.cn/onlinejudge/showP ...
- 杭电ACM分类
杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...
- ZOJ-2965
Accurately Say "CocaCola"! Time Limit: 2 Seconds Memory Limit: 65536 KB In a party he ...
- 转载:hdu 题目分类 (侵删)
转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...
- QDU_组队训练(ABEFGHKL)
A - Accurately Say "CocaCola"! In a party held by CocaCola company, several students stand ...
- ZOJ Problem Set - 1090——The Circumference of the Circle
ZOJ Problem Set - 1090 The Circumference of the Circle Time Limit: 2 Seconds Memory Limit: 65 ...
随机推荐
- quality center 支持的平台
- 退出shell 脚本
#!/bin/bash export TOP_PID=$$ trap 'exit 1' TERM exit_script(){ kill -s TERM $TOP_PID } echo "b ...
- Spring boot 添加日志 和 生成接口文档
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring- ...
- Java 中时间处理 System.currentTimeMillis()
import org.testng.annotations.Test;import java.text.ParseException;import java.text.SimpleDateFormat ...
- [ios][swift]UIButton
参考:http://www.hangge.com/blog/cache/detail_529.html
- Android蓝牙通信功能开发
1. 概述 Bluetooth 是几乎现在每部手机标准配备的功能,多用于耳机 mic 等设备与手机的连接,除此之外,还可以多部手机之间建立 bluetooth 通信,本文就通过 SDK 中带的一个聊天 ...
- Insert Delete GetRandom O(1)
2018-07-15 18:36:29 问题描述: 问题求解: private ArrayList<Integer> ls; private HashMap<Integer, Int ...
- R语言plot函数参数合集
最近用R语言画图,plot 函数是用的最多的函数,而他的参数非常繁多,由此总结一下,以供后续方便查阅. plot(x, y = NULL, type = "p", xlim = N ...
- 错误代码0x00000001,好多软件连不了网,求助~(WIN7/win8/win9/win10)
解决办法: 以管理员身份运行命令行,在弹出的窗口中运行如下命令: netsh winsock reset catalog netsh int ip reset reset.log hit 让被阻止了的 ...
- [Java学习] Java虚拟机(JVM)以及跨平台原理
相信大家已经了解到Java具有跨平台的特性,可以“一次编译,到处运行”,在Windows下编写的程序,无需任何修改就可以在Linux下运行,这是C和C++很难做到的. 那么,跨平台是怎样实现的呢?这就 ...