Submission #15376

# Submission time Handle Problem Language Result Execution time Memory
15376 2015-07-12T06:54:32 Z wlgns88 피보나미얼 (kriii3_V) C++
0 / 74
0 ms 524288 KB
#include <stdio.h>
#include <iostream>

bool chk[1000000000];
int RecursiveFibonacci(int num,unsigned long long& fibonamial){

	if(num==0 || num==1){
		return num;
	}else if(num>=2){ 
		unsigned long long result = RecursiveFibonacci(num-1,fibonamial) + RecursiveFibonacci(num-2,fibonamial); 
		if ( chk[num] == false ) {
			fibonamial = fibonamial*result;
			chk[num]=true;
		}		
		return result;
	} 
} 

int getDivMax(unsigned long long target,int n){
	int i=0;
	while(target%n==0){
		target=target/n;
		i++;
	}
	return i;
}

int main()
{
	int n,p;
	scanf("%d %d",&n,&p);
	
	unsigned long long fibonamial=1;
	RecursiveFibonacci(n,fibonamial);
	//printf("%u\n",fibonamial);
	
	for(int i=1;i<=p-1;i++){
		printf("%d\n",getDivMax(fibonamial,i+1));
	}
}
# Verdict Execution time Memory Grader output
1 Memory limit exceeded 0 ms 524288 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -