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

#if __has_include("D:/dhiraj/Programming/debug.h")
#include "D:/dhiraj/Programming/debug.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define d(...) 11
#endif

// Loops --------------------------------------------------------------------

#define loop(i, s, e) for (ll i = (s); i < (e); i++)
#define rloop(i, s, e) for (ll i = (s); i >= (e); i--)
#define iter(it, var) for (auto it = var.begin(); it != var.end(); it++)
#define riter(it, var) for (auto it = var.rbegin(); it != var.rend(); it++)

// Extra --------------------------------------------------------------------

#define ull unsigned long long int
#define ll long long int
#define ld long double
#define endl '\\n'
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

// Template -----------------------------------------------------------------

template <typename T> inline bool inrange(T a, T l, T r) {
  if (l > r)
    swap(l, r);
  return (a >= l and a <= r);
}
template <typename T, typename U> inline bool exist(T val, U &any) {
  return (any.find(val) != any.end());
}
// multiple input
template <typename T> inline void inp(T &any) { cin >> any; }
template <typename T, typename... U> inline void inp(T &a, U &...b) {
  cin >> a;
  inp(b...);
}
// scan vector
template <typename T> inline istream &operator>>(istream &in, vector<T> &a) {
  for (auto &x : a)
    in >> x;
  return in;
}
// scan pair
template <typename T, typename U>
inline istream &operator>>(istream &in, pair<T, U> &a) {
  in >> a.first >> a.second;
  return in;
}

// Solve --------------------------------------------------------------------

void solve(ll &T) {
  ll n;
  std::cin >> n;

  double x = 100;
  ll year = 0;
  while (x < n) {
    // d(x);
    x += (ll)(x / 100);
    year++;
  }
  std::cout << year << endl;
}

// Main ---------------------------------------------------------------------

int main() {
#ifdef Dhiraj
  freopen("D:/dhiraj/Programming/i1.txt", "r", stdin);
  freopen("D:/dhiraj/Programming/o1.txt", "w", stdout);
#endif

  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);

  int t = 1;
  loop(i, 1, t + 1) {
    cerr << "Case #" << i << "\\n";
    solve(i);
  }
  return 0;
}


Error: TLE

Fixed submission:

#if __has_include("D:/dhiraj/Programming/debug.h")
#include "D:/dhiraj/Programming/debug.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define d(...) 11
#endif

// Loops --------------------------------------------------------------------

#define loop(i, s, e) for (ll i = (s); i < (e); i++)
#define rloop(i, s, e) for (ll i = (s); i >= (e); i--)
#define iter(it, var) for (auto it = var.begin(); it != var.end(); it++)
#define riter(it, var) for (auto it = var.rbegin(); it != var.rend(); it++)

// Extra --------------------------------------------------------------------

#define ull unsigned long long int
#define ll long long int
#define ld long double
#define endl '\\n'
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

// Template -----------------------------------------------------------------

template <typename T> inline bool inrange(T a, T l, T r) {
  if (l > r)
    swap(l, r);
  return (a >= l and a <= r);
}
template <typename T, typename U> inline bool exist(T val, U &any) {
  return (any.find(val) != any.end());
}
// multiple input
template <typename T> inline void inp(T &any) { cin >> any; }
template <typename T, typename... U> inline void inp(T &a, U &...b) {
  cin >> a;
  inp(b...);
}
// scan vector
template <typename T> inline istream &operator>>(istream &in, vector<T> &a) {
  for (auto &x : a)
    in >> x;
  return in;
}
// scan pair
template <typename T, typename U>
inline istream &operator>>(istream &in, pair<T, U> &a) {
  in >> a.first >> a.second;
  return in;
}

// Solve --------------------------------------------------------------------

void solve(ll &T) {
  ll n;
  std::cin >> n;

  double x = 100;
  ll year = 0;
  while (x < n) {
    d(x);
    x += (int)(x / 100);
    year++;
  }
  std::cout << year << endl;
}

// Main ---------------------------------------------------------------------

int main() {
#ifdef Dhiraj
  freopen("D:/dhiraj/Programming/i1.txt", "r", stdin);
  freopen("D:/dhiraj/Programming/o1.txt", "w", stdout);
#endif

  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);

  int t = 1;
  loop(i, 1, t + 1) {
    cerr << "Case #" << i << "\\n";
    solve(i);
  }
  return 0;
}