Skip to content

Instantly share code, notes, and snippets.

@ArthurLoboLobo
Created June 19, 2023 15:02
Show Gist options
  • Save ArthurLoboLobo/a9ba3a4b5306e40b2ea9d2d05666ed37 to your computer and use it in GitHub Desktop.
Save ArthurLoboLobo/a9ba3a4b5306e40b2ea9d2d05666ed37 to your computer and use it in GitHub Desktop.
#include<bits/stdc++.h>
using namespace std;
int main() {
int n, r, p;
cin >> n >> r >> p;
if(n >= p) {
cout << 0 << endl;
}
else {
int infectados_totais = n;
int infectados_novos = n;
for(int i = 1; i <= p; i++) {
infectados_totais+= infectados_novos*r;
infectados_novos = infectados_novos*r;
if(infectados_totais >= p) {
cout << i << endl;
return 0;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment