Advertisement
Josif_tepe

Untitled

Sep 30th, 2023
866
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. #include <queue>
  2. #include <iostream>
  3. #include <vector>
  4. #include <cstring>
  5. #include <iostream>
  6. #include <set>
  7. #include <cstring>
  8. #include <stack>
  9. #include <algorithm>
  10. #include <map>
  11. #include <cmath>
  12. //#include <bits/stdc++.h>
  13. using namespace std;
  14. typedef long long ll;
  15. const int maxn = 3e5 + 10;
  16. const ll INF = 3e16 + 10;
  17. string int_to_string(int x) {
  18.     string res = "";
  19.     while(x) {
  20.         res += (x % 10) + '0';
  21.         x /= 10;
  22.     }
  23.     reverse(res.begin(), res.end());
  24.     return res;
  25. }
  26. int main() {
  27.     ios_base::sync_with_stdio(false);
  28.     string s;
  29.     cin >> s;
  30.    
  31.     int fact = 1;
  32.     map<string, int> mapa;
  33.     for(int i = 1; i <= 10; i++) {
  34.         fact *= i;
  35.         mapa[int_to_string(fact)] = i;
  36.     }
  37.     if(mapa.count(s)) {
  38.         cout << mapa[s] << endl;
  39.         return 0;
  40.     }
  41.     double sum = 0;
  42.     double sz = s.size();
  43.     for(double i = 1; i <= 1000000; i += 1.0) {
  44.         sum += log10(i);
  45.         if(fabs(sz - sum) < 1.0) {
  46.             cout << i << endl;
  47.             return 0;
  48.         }
  49.     }
  50.     return 0;
  51. }
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement