forked from rajatgoyal715/Hackerrank
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSherlockAndBeast.java
More file actions
42 lines (38 loc) · 895 Bytes
/
SherlockAndBeast.java
File metadata and controls
42 lines (38 loc) · 895 Bytes
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
package Greedy;
import java.util.*;
import java.io.*;
/*
* @author -- rajatgoyal715
*/
public class SherlockAndBeast {
public static void func(int n){
int i = n;
if(n>=0){
if(n%3==0){
while(i!=0){
System.out.print(555);
i = i-3;
}
}
else{
func(n-5);
System.out.print(33333);
}
}
else
System.out.println(-1);
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t!=0){
int n = sc.nextInt();
//if(n==1 || n==2 || n==4 || n==7)
// System.out.print(-1);
//else
func(n);
t--;
System.out.println();
}
}
}