Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#includ<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define debug(n) cout<<(n)<<endl;
const ll INF = 2e18 + 99;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
while(t--){
int a, b, n;
cin>>a>>b>>n;
if(b < a){
int temp = a;
a = b;
b = temp;
}
int count = 0;
while(a <= n && b <= n){
if(a <= n){
a += b;
count++;
}
if(a > n){
break;
}
if(b <= n){
b += a;
count++;
}
if(b > n){
break;
}
}
cout<<count<<endl;
}
}
Copy The Code &
Try With Live Editor
Input
2
1 2 3
5 4 100
1 2 3
5 4 100
Output
2
7
7
Demonstration
Codeforcess solution 1368-A A. C+= ,C++, Java, Js and Python,1368-A,Codeforcess solution