I have this code that works for most of the inputs but there are some that throw me error. like " -1000000000000000000 1 1000000000000000000 " for example.
#include <iostream>
#include <cstdio>
using namespace std;
int x,y,m;
int aux=0;
int toPerfect(int a,int b,int per){
if(a >= per || b >= per){
aux=0;
}else if(a<=0 && b<=0){
aux = -1;
}else{
while(a < per && b < per){
if(a > b){
b = b+a;
}else{
a = a+b;
}
aux++;
}
}
return aux;
}
int main(){
cin >>x>>y>>m;
cout << toPerfect(x,y,m) << endl;
cin.get();
}