import java util ArrayList import java util Arrays import java util Sc

 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
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.lang.Math;
public class Dividers {
public static void main(String[] arg) {
Scanner sc = new Scanner(System.in);
ArrayList<Long> divsbig = new ArrayList<Long>();
ArrayList<Long> divslow = new ArrayList<Long>();
long n=sc.nextLong();
int sqrt=(int)Math.sqrt(n),i,count=0;
for(i=1;i<=sqrt;i++){
if(n%i==0){
divsbig.add(n/i);
divslow.add((long)i);
count++;
}
}
if(divsbig.get(count - 1) == divslow.get(count - 1)) {
divslow.remove(count-1);
}
for(i=(divslow.size()-1);i>=0;i--)
{
divsbig.add(divslow.get(i));
}
System.out.println("graph {");
for(i=0,sqrt=divsbig.size();i<divsbig.size();i++) {
System.out.println(" "+divsbig.get(i));
}
for(i=0;i<sqrt;i++)
for(int j=i+1,t=1;j<sqrt;j++)
if((divsbig.get(i)%divsbig.get(j))==0) {
for(count=j-1;count>i;count--) {
if(divsbig.get(count)%divsbig.get(j)==0 && (divsbig.get(i)%divsbig.get(count))==0) {
t = 0;
break;
}
}
if(t==1)
System.out.println(" " + divsbig.get(i) + "--" + divsbig.get(j));
}
System.out.println("}");
}
}