-
Notifications
You must be signed in to change notification settings - Fork 0
/
dislikeofthrees.java
52 lines (47 loc) · 1.25 KB
/
dislikeofthrees.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import java.io.*;
import java.util.*;
import java.util.Arrays;
public class dislikeofthrees {
public static void main(String[] args) {
FastScanner sc = new FastScanner();
PrintWriter pw = new PrintWriter(System.out);
int i=0,x,k=1;
int con[]=new int[1000];
while(i<1000)
{
if((k%3!=0||k%10!=3)&&(k%3!=0&&k%10!=3))
{
con[i]=k;
i++;
}
k++;
}
int T = sc.ni();
int arr[]=new int[T];
for (int t = 0; t< T; t++) {
arr[t]=sc.ni();
pw.println(con[arr[t]-1]);
}
pw.close();
}
static class FastScanner {
BufferedReader br;
StringTokenizer st;
public FastScanner() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int ni() {
return Integer.parseInt(next());
}
}
}