-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathI027.java
More file actions
52 lines (48 loc) · 1.29 KB
/
I027.java
File metadata and controls
52 lines (48 loc) · 1.29 KB
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
package levelB;
import java.util.ArrayList;
import java.util.Scanner;
public class I027 {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
int N=s.nextInt();
char c=s.next().charAt(0);
int count=0,sum=1;
ArrayList<Integer> list=new ArrayList<>();
while(true){
list.add(2*count+1);
count++;
sum+=2*count+1;
if(2*sum-1>N){
break;
}
}
count=0;
for(int i=list.size()-1;i>=0;i--){
for(int j=0;j<count;j++){
System.out.print(" ");
}
for(int k=0;k<list.get(i);k++){
System.out.print(c);
}
count++;
System.out.println();
}
count--;
for(int i=1;i<list.size();i++){
count--;
for(int j=0;j<count;j++){
System.out.print(" ");
}
for(int k=0;k<list.get(i);k++){
System.out.print(c);
}
System.out.println();
}
sum=0;
for(int i=0;i<list.size();i++){
sum+=list.get(i);
}
sum=2*sum-1;
System.out.print(N-sum);
}
}