본문 바로가기

Programming/Solutions

(52)
[Project Euler] Problem 011 (Java)1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677package q001_q025; public class Problem011 { private static int[][] SQUARE = { { 8, 2,22,97,38,15, 0,40, 0,75, 4, 5, 7,78,52,12,50,77,91, 8}, {49,49,99,40,17,81,18,57,60,87,17,40,98,43,69,48, 4,56,62, 0}, {81,49,31,73,55,79,14,29,93,71,40,67,53,88..
[BAEKJOON] 1193번 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950import java.util.Scanner; public class Main { public static void main(String[] args) { System.out.print(new Main().run()); } public String run() { Scanner sc = new Scanner(System.in); int input = sc.nextInt(); int count = 0; int numer = 1, denom = 1; String result = null; for(int i = 1; count 0) { ++count;..
[Project Euler] Problem 010 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152public class Problem010 { private static final int LIMIT = 2000000; public static void main(String[] args) { System.out.println(run()); } public static long sieve() { int div = 2; long sum = 0; int num = 2; int idx = 0; int[] arr = new int[LIMIT - 1]; for(int i = 0; i
[Project Euler] Problem 009 이 문제에서 만족해야 할 a, b, c의 조건은 다음의 세 가지다. ① a, b, c는 a < b < c인 자연수 ② a² + b² = c²③ a + b + c = 1000 내 풀이의 핵심은 조건 ③이다.c를 우변으로 이항하면 a + b = 1000 - c 임을 이용했다. 123456789101112131415161718192021222324252627package q001_q025; public class Problem009 { public static void main(String[] args) { System.out.println(run()); } public static String run() { int a, b, c; int result = 0; for(a = 1; a
[BAEKJOON] 1011번 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950#include #define SQUARE(X) ((X)*(X)) int run();long long warp(long long d); int main(){ return run();} int run(){ int num; long long x, y; scanf("%d", &num); while (--num) { scanf("%lld %lld", &x, &y); printf("%lld\n", warp(y - x)); } return 0;} long long warp(long long d){ long long j; long long min, sqr,..
[Project Euler] Problem 008 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354public class Problem008 { public static void main(String[] args) { System.out.println(run()); } public static int run() { String[] str = { "73167176531330624919225119674426574742355349194934", "96983520312774506326239578318016984801869478851843", "85861560789112949495459501737958331952853208805511"..
[BAEKJOON] 1152번 123456789101112131415161718import java.util.Scanner;import java.util.StringTokenizer; public class Main { public static void main(String[] args) { System.out.print(new Main().run()); } public String run() { Scanner scanner = new Scanner(System.in); StringTokenizer st = new StringTokenizer(scanner.nextLine(), " "); scanner.close(); return Integer.toString(st.countTokens()); }}Colored by Color Scr..
[BAEKJOON] 2775번 각 아파트에 사는 사람을 표로 표현하면 다음과 같다. 1 16 136 … 1 15 120 1 14 105 1 13 91 1 12 78 1 11 66 1 10 55 1 9 45 1 8 36 1 7 28 1 6 21 1 5 15 1 4 10 20 35 56 81 107 152 207 273 351 442 547 1 3 6 10 15 21 28 36 45 55 66 78 91 105 1 2 3 4 5 6 7 8 9 10 11 12 13 14 첫번째 열을 제외하고 대각선 대칭이다. 3-34-6-45-10-10-56-15-20-15-67-21-35-35-21-7... 따라서 n행 n열의 값은 n-1행 n열과 n행n-1열의 값의 합이다. 1234567891011121314151617181920212223242526..