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 ...
随机推荐
- 【U3D】脚本引用的类,如何显示在编辑器界面
有时候,我们的类里面会组合其他功能模块 如何让这些功能类的值在编辑器界面出现呢? 1:引用类的访问类型必须是Public 2: 类必须声明为可序列化的,即在类头加入以下声明 [System.Seria ...
- nmon监控及简要分析
性能测试中,各个服务器资源占用统计分析是一个很重要的组成部分,通常我们使用nmon这个工具来进行监控以及监控结果输出. 一. 在监控阶段使用类似下面的命令 ./nmon -f write_3s_20v ...
- TOSCA自动化测试工具ppt(正在整理)
1. 认识TOSCA 安装使用 2. TOSCA自动化测试工具的优点 1). 可扩展 Tosca Commander™ functionalities can be extended by us ...
- 利用URLConnection来发送POST和GET请求
URL的openConnection()方法将返回一个URLConnection对象,该对象表示应用程序和 URL 之间的通信链接.程序可以通过URLConnection实例向该URL发送请求.读取U ...
- [leetcode刷题笔记]Implement Trie (Prefix Tree)
题目链接 一A,开森- ac代码: class TrieNode { // Initialize your data structure here. char content; boolean isW ...
- 关于Android RenderScript 的详细说明和一些实用文档
http://www.cnblogs.com/TerryBlog/archive/2012/03/02/2377251.html RenderScript 是一种低级的高性能编程语言,用于3D渲染和处 ...
- HCNP学习笔记之HCNP学习的几种境界
前言: 做任何事情都应该遵循一个循序渐进的过程,而这个过程可能是较为枯乏无味的,在我接触的人中主要分为踏实肯学满腹才华和半途而废不思进取两类.故而希望大家成为前者,勿做后者. 第一境界:散漫无序 简单 ...
- 20145310《Java程序设计》第3次实验报告
20145310<Java程序设计>第3次实验报告 实验内容 使用 git 上传代码 使用 git 相互更改代码 实现代码的重载 实验步骤 首先使用git设置用户名和ssh公钥 使用git ...
- 20145230熊佳炜《逆向及BOF基础实践》
20145230熊佳炜<逆向及BOF基础实践> 实践目标 本次实践的对象是一个名为pwn1的linux可执行文件.该程序同时包含另一个代码片段,getShell,会返回一个可用Shell. ...
- java直接计算一个算术题
import javax.script.ScriptEngine;import javax.script.ScriptEngineManager;import javax.script.ScriptE ...