ZOJ 2965 Accurately Say "CocaCola"!(预处理)
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 Tconsecutive 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
Author: HANG, Hang
Source: The 5th Zhejiang Provincial Collegiate Programming Contest
水题:预处理,连续的7的倍数或含数字7
#include <iostream>
#include<cstdio>
using namespace std;
int t,n;
int f[];
bool ok(int k) //是否符合要求,含有数字7或者是7的倍数
{
if (k%==) return ;
while(k)
{
if (k%==) return ;
k=k/;
}
return ;
}
int main()
{
int l=;
for(int i=;i<=;i++)
{
if (ok(i))
{l++; if (!f[l]) f[l]=i-l+;}
else l=;
} //f[i]表示有i个连续的符合要求的最小的是从哪个数开始。
while(~scanf("%d",&t))
{
for(;t>;t--)
{
scanf("%d",&n);
printf("%d\n",f[n]);
}
}
return ;
}
ZOJ 2965 Accurately Say "CocaCola"!(预处理)的更多相关文章
- ZOJ 2965 Accurately Say "CocaCola"!
Time Limit: 2 Seconds Memory Limit: 65536 KB In a party held by CocaCola company, several stude ...
- 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 ...
- ZOJ 刷题记录 (。・ω・)ノ゙(Progress:31/50)
[热烈庆祝ZOJ回归] P1002:简单的DFS #include <cstdio> #include <cstring> #include <algorithm> ...
- 杭电ACM分类
杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...
- 转载:hdu 题目分类 (侵删)
转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...
- ZOJ-2965
Accurately Say "CocaCola"! Time Limit: 2 Seconds Memory Limit: 65536 KB In a party he ...
- QDU_组队训练(ABEFGHKL)
A - Accurately Say "CocaCola"! In a party held by CocaCola company, several students stand ...
随机推荐
- Apache 部署HTTPS
Apache 部署HTTPS 系统:Linux Centos 7.4 x64 应用:Apache 2.4.6 需要安装:mod_ssl 注:确认开启 Include conf/extra/httpd- ...
- Pycharm安装Python第三方库
转自:http://blog.csdn.net/qiannianguji01/article/details/50397046 除了使用easy_insatll和pip工具安装Python第三方库外还 ...
- SaltStack匹配target-第六篇
练习内容 Salt远程执行中目标选择常用的模式 1.通配符匹配 2.正则表达式匹配 3.List支持 4.Grains匹配 5.IP地址匹配 6.混合匹配 7.Node groups 远程执行格式 t ...
- LeetCode——Counting Bits
Question Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calcu ...
- javascript的函数,定义
函数 function A () { }函数体开头 函数名 传入的参数 方法 <button onclick=&qu ...
- 【转】GitHub汉化脚本(谷歌浏览器)
// ==UserScript== // @name GitHub 汉化插件 // @description 汉化 GitHub 界面的部分菜单及内容. // @copyright 2016, 楼教主 ...
- 谈一谈URL
作者:ManfredHu 链接:http://www.manfredhu.com/2017/08/16/22-url/index.html 声明:版权所有,转载请保留本段信息,谢谢大家 URL URL ...
- JAXB和XStream比较
转自:https://www.cnblogs.com/tang9139/p/4825610.html http://www.cnblogs.com/wlsblog/p/7452882.html 这两东 ...
- NNCRF之NNSegmentation, NNPostagging, NNNameEntity
这里主要介绍NNSegmentation 介绍: NNSegmentation是一个基于LibN3L的利用神经网络来进行分词的工具. 他可以通过不同的模型(NN, RNN, GatedNN, LSTM ...
- Linux系统非root用户安装perl模块
非root权限安装perl 在使用Linux或是unix时,perl是一个非常有用的脚本的语言. 关于perl的模块安装,网上也有很多介绍,一方面可以通过不同套件自带的软件安装工具安装,一方面可以通过 ...