답안 #15222

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
15222 2015-07-12T04:07:32 Z abcd123 피보나미얼 (kriii3_V) C
0 / 74
0 ms 8896 KB
#include<stdio.h>

long long cache[1000000];

long long f(int x)
{
	if(x==1||x==2)
	{
		cache[x] = 1;
		return cache[x];
	}
	else
	{
		if(cache[x]==0){
			cache[x] = f(x-1) + f(x-2);
			return cache[x];
		}
		else
			return cache[x];
	}
}

void main()
{
	int num,p,i;
	long long sum = 1, test;
	int arr[100] = {0,};

	scanf("%d %d",&num,&p);
	
	for(i=1;i<=num;i++)
		sum *= f(i);

	for(i=1;i<=p-1;i++){
		test = sum;
		while(1){
			if(test%(i+1) == 0){
				arr[i] += 1;
				test = test/(i+1);
			}
			if(test%(i+1) != 0)
				break;
		}
	}

	for(i=1;i<=p-1;i++)
		printf("%d\n",arr[i]);
	
	//system("PAUSE");
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 8896 KB SIGSEGV Segmentation fault
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Halted 0 ms 0 KB -