STANAANDREY

MY SIM SB3 3

Apr 6th, 2022 (edited)
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. ofstream fout("bac.txt");
  5.  
  6. int getCntOfBaseInNFact(int n, int base) {
  7.     int cnt = 0, powOfBase = base;
  8.     while (n / powOfBase) {
  9.         cnt += n / powOfBase;
  10.         powOfBase *= base;
  11.     }
  12.     return cnt;
  13. }
  14.  
  15. int main() {
  16.     int n;
  17.     cin >> n;
  18.     int fr5 = getCntOfBaseInNFact(n, 5);
  19.     int fr9 = getCntOfBaseInNFact(n, 3) / 2;
  20.     fout << (fr9 > fr5 ? fr5 : fr9) << '\n';
  21.     fout.close();
  22.     return 0;
  23. }
  24.  
Add Comment
Please, Sign In to add comment