답안 #15422

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
15422 2015-07-12T07:27:03 Z wlgns88 피보나미얼 (kriii3_V) C++
0 / 74
0 ms 1720 KB
#include <stdio.h>
#include <iostream>

unsigned long long chk=0;
bool getBit(unsigned long long num,int i){
	return (num&(1<<i));
}

void setBit(unsigned long long& num,int i){
	num = num|(1<<i);
}


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 ( getBit(chk,num) == false ) {
			fibonamial = fibonamial*result;
			setBit(chk,num);
		}
		return result;
	} 
} 

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

int main()
{
	chk = 0;
	int n,p;
	scanf("%d %d",&n,&p);
	
	unsigned long long fibonamial=1;
	RecursiveFibonacci(n,fibonamial);
	
	for(int i=1;i<=p-1;i++){
		printf("%u\n",getDivMax(fibonamial,i+1));
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1720 KB Output is correct
2 Incorrect 0 ms 1720 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Halted 0 ms 0 KB -