国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

ZOJ 2965 Accurately Say "CocaCola"!

2019-11-08 03:05:38
字體:
來源:轉載
供稿:網友

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

223

Sample Output

27

70

簡單題,預處理一下輸出就行

#include<map>#include<ctime>#include<cmath>    #include<queue> #include<string>#include<vector>#include<cstdio>    #include<cstring>  #include<iostream>#include<algorithm>    using namespace std;#define ms(x,y) memset(x,y,sizeof(x))    #define rep(i,j,k) for(int i=j;i<=k;i++)    #define per(i,j,k) for(int i=j;i>=k;i--)    #define loop(i,j,k) for (int i=j;i!=-1;i=k[i])    #define inone(x) scanf("%d",&x)    #define intwo(x,y) scanf("%d%d",&x,&y)    #define inthr(x,y,z) scanf("%lf%lf%lf",&x,&y,&z)    typedef long long LL;const int low(int x) { return x&-x; }const int INF = 0x7FFFFFFF;const int mod = 1e9 + 7;const int N = 1e5 + 10;int T, n;int f[100];int g[N];int main(){	ms(f, 1);	rep(i, 1, N - 1)	{		g[i] = i % 7 == 0;		for (int j = i; j; j /= 10) g[i] |= j % 10 == 7;	}	per(i, N - 2, 1)	{		g[i] = g[i] * (g[i] + g[i + 1]);		f[min(g[i], 99)] = i;	}	per(i, 98, 1) f[i] = min(f[i], f[i + 1]);	for (inone(T); T--;)	{		inone(n); PRintf("%d/n", f[n]);	}	return 0;}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 锡林郭勒盟| 财经| 海南省| 安徽省| 彩票| 宁强县| 卫辉市| 辽中县| 马关县| 扎兰屯市| 丹棱县| 镇原县| 凌海市| 万全县| 财经| 克东县| 华池县| 泰兴市| 台南市| 神农架林区| 尼勒克县| 当阳市| 郁南县| 紫阳县| 肃南| 鸡西市| 军事| 宁蒗| 江阴市| 阿勒泰市| 张北县| 临洮县| 永修县| 泗阳县| 浪卡子县| 安陆市| 乐山市| 怀仁县| 烟台市| 延安市| 平安县|