Submission #9242

# Submission time Handle Problem Language Result Execution time Memory
9242 2014-09-28T04:58:33 Z sior Phibonacci (kriii2_P) C++
0 / 4
0 ms 1852 KB
#include <iostream>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

typedef long long ll;

ll fn(ll n);

int main()
{
	long long int n, k;

	cin >> n >> k;
	
	long long a = 1, b = 1;
	long long ret = 2;

	if (n == 0)
	{
		cout << 0 << " " << 1;
		return 0;
	}
	else if (n == 1)
	{
		cout << 1 << " "<<0;
		return 0;
	}
	else if (n == 2)
	{
		cout << 1 << " " << 1 << endl;
		return 0;
	}

	cout << fn(n) << " "<<fn(n - 1) << endl;
	return 0;

}

ll fn(ll n)
{
	double ret = 0;
	double a = pow((1 + sqrt(5)) / 2,n);
	double b = pow((1 - sqrt(5)) / 2, n);
	ret = (a - b) / sqrt(5);

	return (ll)ret;
	
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1852 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -