RECUR1 - Recursive World!!!
See following the two recursive functions,
C (0) =0
C (1) =5
C (K) =C (K-1) + 4
F (0) = 1
F (1) = 2
F (N) =F (N-1) + C (N-1)
Now you are given N, you have to find the value of F (N).
Input:
Input starts with an integer T, denoting the number of test cases. Each test case contains an integer N
Constraints
T<=1000000
0<=N<=1000000000
Output:
For each test case, print the value of F (N). The value of F (N) fits in 64-bit signed integer.
Sample Input Sample Output
2
3
5
16
46
See following the two recursive functions,
C(0) = 0
C(1) = 5
C(K) = C(K-1) + 4
F(0) = 1
F(1) = 2
F(N) = F(N-1) + C(N-1)
Now you are given N, you have to find the value of F (N).
Input:
Input starts with an integer T, denoting the number of test cases. Each test case contains an integer N
Constraints
T<=800000
0<=N<=1000000000
Output:
For each test case, print the value of F (N). The value of F (N) fits in 64-bit signed integer.
Sample Input |
Sample Output |
2 3 5 |
16 46
|
Problem Setter: Md Abdul Alim, Dept. of Computer Science, Bangladesh University of Business & Technology
Added by: | Alim |
Date: | 2016-03-02 |
Time limit: | 2s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 GOSU JS-MONKEY |
Resource: | Own Problem |