This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
long long int chk=0;
bool getBit(long long int num,long long int i){
return (num&(1<<i));
}
void setBit(long long int& num,long long int i){
num = num|(1<<i);
}
long long int RecursiveFibonacci(long long int num,long long int& fibonamial){
if(num==0 || num==1){
return num;
}else if(num>=2){
long long int result = RecursiveFibonacci(num-1,fibonamial) + RecursiveFibonacci(num-2,fibonamial);
if ( getBit(chk,num) == false ) {
fibonamial = fibonamial*result;
setBit(chk,num);
}
return result;
}
}
long long int getDivMax(long long int target,long long int n){
unsigned long long i=0;
while(target%n==0){
target=target/n;
i++;
}
return i;
}
int main()
{
chk = 0;
long long int n,p;
scanf("%lld %lld",&n,&p);
long long int fibonamial=1;
RecursiveFibonacci(n,fibonamial);
for(long long int i=1;i<=p-1;i++){
printf("%lld\n",getDivMax(fibonamial,i+1));
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |