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"!的更多相关文章

  1. ZOJ 2965 Accurately Say "CocaCola"!(预处理)

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

  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. 杭电ACM分类

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

  6. ZOJ-2965

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

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

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

  8. QDU_组队训练(ABEFGHKL)

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

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

随机推荐

  1. CRLF line terminators导致shell脚本报错:command not found --转载

    Linux和Windows文本文件的行结束标志不同.在Linux中,文本文件用"/n"表示回车换行,而Windows用"/r/n"表示回车换行.有时候在Wind ...

  2. codeforces 350 div2 D Magic Powder - 2 二分

    D2. Magic Powder - 2 time limit per test 1 second memory limit per test 256 megabytes input standard ...

  3. vim/vi中移动光标键会变成A,B,C,D的解决办法

    在某些情况下, vi/vim中的编辑会出现一些很不愉快的情况, 比如在vi/vim中输入方向键有时被转化为A B C D, 或者按个Enter键, 却被转为为其他字母, 恼人得很, 该怎么办呢? 方法 ...

  4. STL__网上资料

    1. http://bbs.csdn.net/topics/370029802 #include <iostream> #include <limits> #include & ...

  5. 《剑指offer》第三十四题(二叉树中和为某一值的路径)

    // 面试题34:二叉树中和为某一值的路径 // 题目:输入一棵二叉树和一个整数,打印出二叉树中结点值的和为输入整数的所 // 有路径.从树的根结点开始往下一直到叶结点所经过的结点形成一条路径. #i ...

  6. Unity中的文件

    Unity中的文件大致分为一下几类: 1.资源文件: 导入后,除非是修改,否则不会变化的文件.例如:fbx文件.贴图文件.音频文件.视频文件.动画文件等. 这些文件在导入到Unity的时候,都会进行转 ...

  7. Xshell Xftp 免费版 (xshell6 评估期已过 解决办法)

    xshell6 评估期已过,因为下载的版本是evaluation版本,是有期限的. 大家可以修改为Home and school use 的版本,这样就不会出现这个提示了. 具体的操作步骤如下: 1. ...

  8. [.NET开发] C#实现的SQL备份与还原功能示例

    本文实例讲述了C#实现的SQL备份与还原功能.分享给大家供大家参考,具体如下: //记得加 folderBrowserDialog1 openFileDialog1 控件 using System.D ...

  9. mRNA基本概念

    mRNA是由DNA的一条链转录而来的(可以是正链,也可以是反链),DNA是由非编码区和编码区组成,编码区也有其特殊的结构,主要有外显子和内含子组成. mRNA的一个重要性质就是可变剪切,也就是同一个编 ...

  10. Android之ToolBar的使用

    Toolbar是在 Android 5.0 开始推出的一个 Material Design 风格的导航控件 ,Google 非常推荐大家使用 Toolbar 来作为Android客户端的导航栏,以此来 ...