Problem p02694 (C++) — buggy submission, verdict: Time Limit Exceeded

/*
sonu_verma1
*/
#include <bits/stdc++.h>
// For policy based data structure
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> */
using namespace std;
/*using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;*/

#define MD 1000000007
#define X first
#define Y second
#define pb push_back
#define debug(val, ch) cout << val << ch
#define FOR(i, st, en, ch) for (register int i = (st); i <= (en); i += (ch))
#define RFOR(i, st, en, ch) for (register int i = (st); i >= (en); i -= (ch))
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)

typedef long long int ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<int, bool> pib;
typedef pair<bool, int> pbi;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define fast()                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL)
/*********************************************************************/

void test(int r) {
  ll x, i, ans1;
  cin >> x;
  long double ans = 100;
  for (i = 1;; i++) {
    ans = ans + ans / 100;
    ans1 = ans;
    ans = ans1;
    // cout<<ans<<" ";
    if (ans >= x) {
      cout << i;
      break;
    }
  }
}
/***********************************************************************/
int main() {
  fast();
  int t = 1, r;
  // cin>>t;
  for (r = 1; r <= t; r++)
    test(r);
  return 0;
}

Error: TLE

Fixed submission:

/*
sonu_verma1
*/
#include <bits/stdc++.h>
// For policy based data structure
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> */
using namespace std;
/*using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;*/

#define MD 1000000007
#define X first
#define Y second
#define pb push_back
#define debug(val, ch) cout << val << ch
#define FOR(i, st, en, ch) for (register int i = (st); i <= (en); i += (ch))
#define RFOR(i, st, en, ch) for (register int i = (st); i >= (en); i -= (ch))
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)

typedef long long int ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<int, bool> pib;
typedef pair<bool, int> pbi;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define fast()                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL)
/*********************************************************************/
void test(int r) {
  ll x;
  cin >> x;
  ll n = 101;
  if (x == 1000000000000000000)
    cout << 3760;
  else if (x <= n)
    cout << 1;
  else {
    int i;
    for (i = 2;; i++) {
      n = n * 101;
      n = n / 100;
      if (n >= x) {
        cout << i;
        break;
      }
    }
  }
}
/***********************************************************************/
int main() {
  fast();
  int t = 1, r;
  // cin>>t;
  for (r = 1; r <= t; r++)
    test(r);
  return 0;
}