목록전체 글 (601)
sm 기술 블로그
import sys input = sys.stdin.readline input() num = list(map(int, input().split())) result = "" def GCD(x, y): while(y != 0): r = x % y x = y y = r return x numFirst = num[0] for i in range(1, len(num)): if(numFirst % num[i] == 0): result += str(int(numFirst / num[i])) + "/1\n" else: numGCD = GCD(numFirst, num[i]) result += str(int(numFirst / numGCD)) + "/" + \ str(int(num[i] / numGCD)) + "\n" p..
import java.util.*; import java.io.*; class Main{ public static void main(String args[])throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ArrayList num = new ArrayList(); HashSet numSet = new HashSet(); int T = Integer.parseInt(br.readLine()); for(int i = 0; i< T; i++) { num.add(Integer.parseInt(br.readLine())); } Collections.sort(num); int numGCD = nu..
import sys input = sys.stdin.readline T = int(input()) num = sorted([int(input()) for _ in range(T)]) result = set() def GCD(x, y): while(y != 0): r = x % y x = y y = r return x numGCD = num[1]-num[0] for i in range(2, T): numGCD = GCD(numGCD, abs(num[i]-num[i-1])) for j in range(2, int(numGCD**0.5)+1): if(numGCD % j == 0): result.add(j) result.add(numGCD//j) result.add(numGCD) print(*sorted(lis..
import java.util.*; import java.io.*; class Main{ public static void main(String args[])throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); int T = Integer.parseInt(br.readLine()); for(int i = 0; i < T; i++) { String[] sBits = br.readLine().split(" "); int x = Integer.parseInt(sBits[0]); int y = Integer.parseInt(s..