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. addEventListener、onclick和jquery的bind()、click()

    addEventListener("click",function(event){},false); removeEventListener("click",f ...

  2. 如何在Kubernetes集群动态使用 NAS 持久卷

    1. 介绍: 本文介绍的动态生成NAS存储卷的方案:在一个已有文件系统上,自动生成一个目录,这个目录定义为目标存储卷: 镜像地址:registry.cn-hangzhou.aliyuncs.com/a ...

  3. snapshot与release

    总结自:https://www.jianshu.com/p/084fd2408d9a 这两个概念是用于描述jar包,jar包提供给其他系统作为依赖. 1. snapshot版本代表不稳定.尚处于开发中 ...

  4. 20145313张雪纯 《Java程序设计》第3周学习总结

    20145313张雪纯 <Java程序设计>第3周学习总结 教材学习内容总结 4.1.1 定义类 package four; class Clothes{ String color; ch ...

  5. 20145313张雪纯 《Java程序设计》第2周学习总结

    20145313张雪纯 <Java程序设计>第2周学习总结 教材学习内容总结 3.1.1类型 整数:分为short整数(2字节).int整数(4字节).long整数(8字节). 字节:by ...

  6. obtainBuffer timed out (is the CPU pegged?)

    https://stackoverflow.com/questions/5293025/audiotrack-lag-obtainbuffer-timed-out [典] 03-13 14:55:57 ...

  7. MySQL优化具体

    1. 查询与索引优化分析 在优化MySQL时,通常需要对数据库进行分析,常见的分析手段有慢查询日志,profiling分析,EXPLAIN分析查询,以及show命令查询系统状态及系统变量,通过定位分析 ...

  8. 【读书笔记】《深入浅出nodejs》第一章 Node简介

    1. Node的官方网站: http://nodejs.org 2. Node的缘起: Ryan Dahl 打算设计一个高性能的Web服务器. Ryan Dahl 认为设计高性能Web服务器的要点在于 ...

  9. 解决 libnanomsg.so.0: cannot open shared object file: No such file or directory 无法找到libnanomsg动态链接库

    参考: [11]缺少动态连接库.so--cannot open shared object file: No such file or directory Importing Issues: cann ...

  10. 对spring boot 之AutoConfiguration 的理解

    来自:http://rensanning.iteye.com/blog/2363467 https://blog.csdn.net/tincox/article/details/79186067 Au ...