-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSolution.java
58 lines (55 loc) · 887 Bytes
/
Solution.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
53
54
55
56
57
58
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
int T=Integer.parseInt(args[0]),num=0;
for(int i=1;i<=T;i++)
{
int N=Integer.parseInt(args[i]);
if(N%5!=0 && N%3!=0)
System.out.println(-1);
else
if(N%3==0 && N%5!=0)
{
for(int j=0;j<N;j++)
{
num+=5*(int)Math.pow(10,j);
}
}
else
if(N%5==0 && N%3!=0)
{
for(int j=0;j<N;j++)
{
num+=3*(int)Math.pow(10,j);
}
}
/*else
{
if(N%3==0 && N%5==0)
{
int a=0;
for(int k=N;k>0;k--)
{
if(k%3==0 && (N-k)%5==0)
a=k;
}
int b=N-a;
for(int h=0;h<b;h++)
{
num+=3*(int)Math.pow(10,h);
}
for(int j=b;j<N;j++)
{
num+=5*(int)Math.pow(10,j);
}
}
}
}*/
System.out.println(num);
}
}