-
-
Notifications
You must be signed in to change notification settings - Fork 109
Expand file tree
/
Copy pathBeautiful3Set.java
More file actions
29 lines (27 loc) · 722 Bytes
/
Beautiful3Set.java
File metadata and controls
29 lines (27 loc) · 722 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
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) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int max = n/3*2;
if (n%3==2)
max++;
int sn = n;
if (n%3==1)
sn--;
System.out.println(max+1);
int first = max;
for (int i = (max+1)/2; i >= 0; i--) {
System.out.println(first+" "+i+" "+(n-i-first));
first--;
}
for (int i = sn-first-1; first >= 0; i--) {
System.out.println(first+" "+i+" "+(n-i-first));
first--;
}
}
}