# DCP-185: Maximum Difference Back to All Problems

Medium Math > Basic Math

I love problems with short descriptions. I believe you love them too. Let's go for it. Given two recursive functions - **f(n) = f(n - 1) + g(n - 2)**, if n > 1 **g(n) = g(n - 1) + f(n - 2)**, if n > 1 Here, **f(0) = a1**, **f(1) = b1**, **g(0) = a2**, **g(1) = b2** Let's define **d(n) = |f(n) - g(n)|**, ( absolute difference of f(n) and g(n) ) If these functions continue infinitely, find the **maximum** value of **d(n)**. Input: ------ Input starts with an integer **T (T <= 100)**, denoting the number of test cases. Each case contains four integer **a1**, **b1**, **a2**, **b2** which are already described. Here, **1 <= a1, b1, a2, b2 <= 1,000,000** Output: ------- For each test case print the case number and the maximum value of **d(n)**. Sample Input ------------ 2 12 33 45 21 32 23 67 90 Sample Output ------------- Case 1: 45 Case 2: 67

### Problem Limits

 Language Time Limit (seconds) C 2.00 C++ 2.00 C++14 2.00 C# 3.00 Go 3.00 Java 3.00 JavaScript 3.00 Objective-C 3.00 Perl 3.00 PHP 3.00 Python 3.00 Python3 3.00 Ruby 3.00 VB.Net 3.00

# 81/148

Solve/Submission

### Ranking

# User Language Timing
02 pulak_ict_mbstu Cpp14 0.00s
03 nasif2587 Cpp14 0.00s
04 rayhan50001 Cpp14 0.00s
05 anik_JU Cpp14 0.00s
07 anowar1112 Cpp14 0.00s
08 sayedgkm Cpp14 0.00s
09 imunir Cpp14 0.00s
10 n_orbit Cpp14 0.00s
11 Masum_ice Cpp14 0.00s
12 Jisancse Cpp14 0.00s
13 skmonir Cpp14 0.00s
14 fearless_hasan Cpp14 0.00s
15 Dariwala Cpp14 0.00s
16 hiddenhopes Cpp14 0.00s
17 Tanmoy_Datta Cpp14 0.00s
18 prdx9_abir Cpp14 0.00s
19 KIRIN_36 Cpp14 0.00s
20 PKP_007 Cpp14 0.00s
21 SKL12 Cpp14 0.00s
22 rafy Cpp14 0.00s
23 sazal_dev Cpp14 0.00s
24 MAHRahat Cpp14 0.00s
26 feodorv Cpp14 0.00s
27 Morass Cpp14 0.00s
28 mhiceiuk Cpp 0.00s
29 Tahmid Cpp14 0.00s
30 rockersabbir Cpp 0.01s
31 ammasum Cpp14 0.01s
32 limlim Cpp14 0.01s
33 seyedssz Cpp14 0.01s
34 MazedRupok Cpp14 0.01s
35 Reayz Cpp14 0.01s
36 tariqiitju Cpp14 0.01s
37 Rajib_119 Cpp14 0.01s
38 ehsan_sshuvo Cpp14 0.01s
39 froghramar Cpp14 0.01s
40 ssavi Cpp14 0.01s
41 BishalG Cpp14 0.01s
42 alhelal_cse Cpp14 0.01s
43 Puja1409 Cpp14 0.01s
44 moshiur_cse15 Cpp14 0.01s
45 emrul Cpp14 0.01s
46 Tanmoy1228 Cpp14 0.01s
47 Knight_King Cpp14 0.01s
48 Dragon_Curve Cpp14 0.01s
49 mamun4122 Cpp14 0.01s