国产探花免费观看_亚洲丰满少妇自慰呻吟_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;}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 定西市| 定结县| 富锦市| 涞水县| 吉隆县| 古丈县| 银川市| 南澳县| 马关县| 兴海县| 莎车县| 黔西| 玛多县| 绥芬河市| 商丘市| 邻水| 夏邑县| 女性| 环江| 泗阳县| 资源县| 泰宁县| 定日县| 龙陵县| 两当县| 张掖市| 勃利县| 藁城市| 宁远县| 庆安县| 榆树市| 娱乐| 临漳县| 宕昌县| 通城县| 甘肃省| 兰溪市| 辽宁省| 通道| 开化县| 林甸县|