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 ...
随机推荐
- jquery Treeview插件的使用及复选框的级联
本文是对jquery的Treeview插件使用的实例介绍 效果图如下: 文件结构如下:
- mellanox RDMA RoCE
一:首先根据系统发行版本下载对应的驱动,下载地址如下: http://www.mellanox.com/page/products_dyn?product_family=26&mtag=lin ...
- [Deep Learning]学习资料积累
1. ufldl教程√ Andrew Ng的教程,matlab代码. 2. Neural Network and Deep Learning√: 一本未写完的书,非常细致,对基础的概念比如cross ...
- Laravel核心解读--异常处理
异常处理是编程中十分重要但也最容易被人忽视的语言特性,它为开发者提供了处理程序运行时错误的机制,对于程序设计来说正确的异常处理能够防止泄露程序自身细节给用户,给开发者提供完整的错误回溯堆栈,同时也能提 ...
- nginx之proxy、cache、upstream模块学习
nginx之proxy反向代理模块: location ^~ /proxy_path/ { root "/www/html"; 这里没必要配置 index index.html; ...
- 20145231熊梓宏 《网络对抗》 实验9 Web安全基础实践
20145231熊梓宏 <网络对抗> 实验9 Web安全基础实践 基础问题回答 1.SQL注入攻击原理,如何防御? •SQL注入攻击就是通过把SQL命令插入到Web表单递交或输入域名或页面 ...
- cogs 547:[HAOI2011] 防线修建
★★★☆ 输入文件:defense.in 输出文件:defense.out 简单对比 时间限制:1 s 内存限制:128 MB 题目描述: 近来A国和B国的矛盾激化,为了预防不测,A国 ...
- 【前端】jQuery选择器$()的实现原理
今天三七互娱技术面试的时候面试官问了我这个问题,当时一脸懵逼,于是好好总结一下. 当我们使用jquery选择器的时候,$(s).回默认去执行jquery内部封装好的一个init的构造函数每次申明一个j ...
- svn的分支
svn的分支使用 新建一个项目的时候,选择建立自带trunk,branches和tags文件夹的. 其中trunk作为主开发. 有需要的时候,从trunk创建分支到对应的branches下面,新建分支 ...
- Tachyon:Spark生态系统中的分布式内存文件系统
转自: http://www.csdn.net/article/2015-06-25/2825056 摘要:Tachyon把内存存储的功能从Spark中分离出来, 使Spark可以更专注计算的本身, ...