본문 바로가기

반응형

코딩 테스트/Project Euler @ kr

(46)
53) 1 ≤ n ≤ 100 일때 nCr의 값이 1백만을 넘는 경우는 모두 몇 번? http://euler.synap.co.kr/prob_detail.php?id=53 Skillist 설명--------------------------------------------------------------------------------- public static void main (String[] args){int total = 0;for(int n=1;n1;down--){result = result.divide(BigInteger.valueOf(down));}if(result.compareTo(BigInteger.valueOf(999999)) == 1){total+=1;}}}System.out.println(total);}
52) 2배, 3배, 4배, 5배, 6배의 결과도 같은 숫자로 이루어지는 가장 작은 수 http://euler.synap.co.kr/prob_detail.php?id=52 간만에 쉬운 문제 Skillist 설명--------------------------------------------------------------------------------- public static void main (String[] args){int start = 1;for(int i=start;i
51) 일부 숫자를 치환했을 때 8개의 서로 다른 소수가 생기는 가장 작은 소수 http://euler.synap.co.kr/prob_detail.php?id=51 제 코드 말고 다른 분 코드 보세요.머리가 안돌아가서 꾸역꾸역 풀었네요. Skillist 설명--------------------------------------------------------------------------------- public static void main (String[] args){boolean sosuTF[] = new boolean[10000001];//0~1000000int maxsu = 0;sosuTF[0]=true;sosuTF[1]=true; for(int i=2;i
50) 1백만 이하의 소수 중 가장 길게 연속되는 소수의 합으로 표현되는 수는? http://euler.synap.co.kr/prob_detail.php?id=50 에라토스테네스의 체를 사용하여 (합성수의 배수를 지우는 것) 소수 0번째부터 마지막까지의 합을 구함 (사실 소수의 합이 1000000을 넘지 않을때 까지) (0번째 부터 i번째 까지의 합) - (0번째 부터 j번째 까지의 합) = (j+1번째 부터 i번째 까지의 합) 을 이용 ex)(1~10의 합) - (1~8의 합) = (9~10의 합) 55 - 36 = 19 Skillist 설명--------------------------------------------------------------------------------- public static void main (String[] args){boolean sosuTF..
49) 세 항이 소수이면서 다른 수의 순열이 되는 4자리 숫자의 등차수열 찾기 http://euler.synap.co.kr/prob_detail.php?id=49 Skillist 설명--------------------------------------------------------------------------------- public static void main (String[] args){LinkedList sosu = new LinkedList();for(int i = 1001; i
45) 오각수와 육각수도 되는, 40755 다음으로 큰 삼각수는? http://euler.synap.co.kr/prob_detail.php?id=45 육각수는 삼각수에 포함되기 때문에 육각수이면 무조건 삼각수 입니다.따라서 오각수이면서 육가수인 수를 찾으면 됩니다. Skillist 설명--------------------------------------------------------------------------------- public static void main (String[] args){HashSet su5 = new HashSet();//오각수 집합int max = 1;long su5max = 0;long j = 1;long temp;int su = 0;while(true){for(long i=max;i
44) 합과 차도 모두 오각수인 두 오각수 차의 최소값은? http://euler.synap.co.kr/prob_detail.php?id=44 Skillist 설명--------------------------------------------------------------------------------- public static void main (String[] args){HashSet ogagsu = new HashSet();for(int i=1;i
47) 서로 다른 네 개의 소인수를 갖는 수들이 처음으로 네 번 연속되는 경우는? http://euler.synap.co.kr/prob_detail.php?id=47 Skillist 설명--------------------------------------------------------------------------------- public static void main (String[] args){HashSet total = new HashSet();HashSet temp = new HashSet();for(int i=100;;i++){int now = i;for(int j=2;j
46) (소수 + 2×제곱수)로 나타내지 못하는 가장 작은 홀수인 합성수는? http://euler.synap.co.kr/prob_detail.php?id=46 Skillist 설명--------------------------------------------------------------------------------- public static void main (String[] args){HashSet sosu = new HashSet();int now;for(int i=2;;i++){int j;for(j=2;j result*result*2 ){if(sosu.contains(i - (result*result*2))){j=-1;break;}result+=1;}if(j!=-1){System.out.println(i);return ;}}}}}
48) 11 + 22 + 33 + ... + 10001000 의 마지막 10자리 http://euler.synap.co.kr/prob_detail.php?id=48 Skillist 설명--------------------------------------------------------------------------------- public static void main (String[] args){long result = 0l, temp=0l;for(int i=1;i

반응형