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"!(预处理)的更多相关文章

  1. ZOJ 2965 Accurately Say "CocaCola"!

    Time Limit: 2 Seconds      Memory Limit: 65536 KB In a party held by CocaCola company, several stude ...

  2. ZOJ2965 Accurately Say "CocaCola"! 线性扫描

    Accurately Say "CocaCola"! 范围找到:1--700左右,然后打表就ok了 #include<cstdio> #include<cstdl ...

  3. 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 ...

  4. nenu contest3 The 5th Zhejiang Provincial Collegiate Programming Contest

    ZOJ Problem Set - 2965 Accurately Say "CocaCola"!  http://acm.zju.edu.cn/onlinejudge/showP ...

  5. ZOJ 刷题记录 (。・ω・)ノ゙(Progress:31/50)

    [热烈庆祝ZOJ回归] P1002:简单的DFS #include <cstdio> #include <cstring> #include <algorithm> ...

  6. 杭电ACM分类

    杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...

  7. 转载:hdu 题目分类 (侵删)

    转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...

  8. ZOJ-2965

    Accurately Say "CocaCola"! Time Limit: 2 Seconds      Memory Limit: 65536 KB In a party he ...

  9. QDU_组队训练(ABEFGHKL)

    A - Accurately Say "CocaCola"! In a party held by CocaCola company, several students stand ...

随机推荐

  1. vector 迭代 删除指定的元素

    std::vector< Bullet * > m_vBullets; std::vector< Bullet * > m_vRemoveBulltes; ){ for ( s ...

  2. 如何高效的遍历HashMap 以及对key 进行排序

    Map<Integer ,Object> map = new HashMap<Integer,Object>(); for(int i = 0; i<=100;i++){ ...

  3. C++文件路径的写法

    转自:http://blog.csdn.net/chengonghao/article/details/51057780 文件路径的表示可以分为绝对路径和相对路径: c++中\\是一种转义字符,他表示 ...

  4. 自制mysql的rpm包

    MySQL安装一般使用RPM或者源码安装的方式.RPM安装的优点是快速,方便.缺点是不能自定义安装目录.如果需要调整数据文件和日志文件的存放位置,还需要进行一些手动调整.源码安装的优点是可以自定义安装 ...

  5. 20145302张薇《Java程序设计》第十周学习总结

    20145302 <Java程序设计>第十周学习总结 客户端和服务器端功能 客户端程序功能列表: 接收用户控制台输入 判断输入内容是否合法 按照协议格式发送数据 根据服务器端的反馈给出相应 ...

  6. 20145331 《Java程序设计》第8周学习总结

    20145331 <Java程序设计>第8周学习总结 教材学习内容总结 14.NIO与NIO2 高级的输入输出处理,可以使用NIO(New IO),NIO2是文件系统的API Channe ...

  7. 20144303 《Java程序设计》第一周学习总结

    20144303 <Java程序设计>第一周学习总结 教材学习内容总结 下载.安装.调试了JDK. JavaSE是各语言个应用平台的基础,分为四个主要的部分:JVE,JRE,JDK,和ja ...

  8. 再谈CSS动画 - 说点不知道的(一)贝塞尔曲线

    今天重新翻看<CSS 揭秘>"过渡与动画"一章,并把该章代码重新敲了一遍,代码托管在我的Github,在此总结一些心得. 动画的奥秘 在网页中添加动画的目的是让用户有更 ...

  9. openwrt的编译系统是如何制作根文件系统的

    答:分析以下makefile即可获取整个过程 以nxp layerscape系统的编译过程为例 1.分析target/linux/layerscape/image/Makefile的最后一句,这是一个 ...

  10. 推荐个非常简单好用的AOP -- MrAdvice

    https://github.com/ArxOne/MrAdvice 太简单了,写好自己的处理类, 作为Attribute加到要拦截的方法或者类上就可以了. Here is the minimal s ...