ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Codeforces Round #739 (Div. 3) A. Dislike of Threes

2021-10-08 20:04:18  阅读:1019  来源: 互联网

标签:11 10 int Threes Codeforces Polycarp test integer Round


题目链接:Problem - A - Codeforces

Polycarp doesn't like integers that are divisible by 33 or end with the digit 33 in their decimal representation. Integers that meet both conditions are disliked by Polycarp, too.

Polycarp starts to write out the positive (greater than 00) integers which he likes: 1,2,4,5,7,8,10,11,14,16,…1,2,4,5,7,8,10,11,14,16,…. Output the kk-th element of this sequence (the elements are numbered from 11).

Input

The first line contains one integer tt (1≤t≤1001≤t≤100) — the number of test cases. Then tt test cases follow.

Each test case consists of one line containing one integer kk (1≤k≤10001≤k≤1000).

Output

For each test case, output in a separate line one integer xx — the kk-th element of the sequence that was written out by Polycarp.

Example

input

Copy

10
1
2
3
4
5
6
7
8
9
1000

output

Copy

1
2
4
5
7
8
10
11
14
1666

题意:1-1666的序列除去3的倍数和个位为3的数后输出第k个

#include<bits/stdc++.h>
using namespace std;

int arr[2000];

int main(){
	int t;
	int ans= 1;
	for(int i = 1; i<= 1666; i++){
		if(i % 3 != 0 && i % 10 != 3){
			arr[ans++] = i;
		}
	}
	int n;
	cin >> t;
	while(t--){
		cin >> n;
		cout << arr[n] << endl;
	}
	return 0;
}

标签:11,10,int,Threes,Codeforces,Polycarp,test,integer,Round
来源: https://blog.csdn.net/m0_55682843/article/details/120658676

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有