#include <iostream> #include <algorithm> using namespace std; int main() { int n=0; cin>>n; int a=0; int b=1; int c=a+b; int ans=n; while(n-c>=0) { ans=min(ans,n-c); a=b; b=c; c=a+b; } ans=min(c-n,ans); cout<<ans; return 0; }
#include <iostream> #include <algorithm> using namespace std; int main() { int n=0; cin>>n; int a=0; int b=1; int c=a+b; int ans=n; while(n-c>=0) { ans=min(ans,n-c); a=b; b=c; c=a+b; } ans=min(c-n,ans); cout<<ans; return 0; }