Nefu number of bits of fibs 461 (matrix)

Source: Internet
Author: User
fibs number of digits
problem:461 Time limit:1000ms Memory limit:65536k
Description
The generalized Fibonacci sequence is defined as follows:
R0=a; R1= b; rn= uRn-1 + vRn-2 (n >= 3) Here a,b,u,v are real numbers, called RN for the generalized Fibonacci sequence. Now let you calculate the number of bits of the generalized Fibonacci sequence.
input
There are several groups of input data, each group of 1 rows Total 5, respectively, representing N,a,b,u,v,n is a positive integer, A,b,u,v is a real number, and u*u+4v>=0,200<=n<=100000000.
Output
The number of digits of the output RN.
Sample_input
1 2 1 1
250 1 2 1 1
Sample_output

53
hint
Source
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm >
#define LL long long
using namespace std;
int main ()
{
	ll a,b,u,v,n;
	while (scanf ("%lld%lld%lld%lld%lld", &n,&a,&b,&u,&v)!=eof)
	{
		double c=sqrt (u*u+4*v) ;
		Double x= (u+c)/2.0;
		Double y= (u-c)/2.0;
		Double ans=n*log10 (x) +log10 (b-y*a)-log10 (c);
		printf ("%lld\n", (ll) ans+1);
	}
	return 0;


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.