fork download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <cstdlib>
  4. #include <climits>
  5. #include <cstring>
  6. #include <utility>
  7. #include <vector>
  8. #include <string>
  9. #include <cstdio>
  10. #include <bitset>
  11. #include <ctime>
  12. #include <cmath>
  13. #include <stack>
  14. #include <list>
  15. #include <set>
  16. #include <map>
  17.  
  18. using namespace std;
  19.  
  20. #define sci stack <int>
  21. #define vci vector <int>
  22. #define vcs vector <string>
  23. #define vcd vector <double>
  24. #define vci64 vector <long long>
  25. #define seti set <int>
  26. #define mseti multiset <int>
  27. #define PI 3.141592653589
  28. #define EX 2.718281828459
  29.  
  30. const int maxn = 100000 + 5;
  31. const int maxm = 100000 + 5;
  32.  
  33. typedef unsigned int uint;
  34. typedef long long int64;
  35. typedef unsigned long long uint64;
  36.  
  37. template <class T> inline T Sqr(const T & x) { return x * x; }
  38. template <class T> inline T Abs(const T & x) { return x > 0 ? x : -x; }
  39. template <class T> inline T Min(const T & a, const T & b) { return a < b ? a : b; }
  40. template <class T> inline T Max(const T & a, const T & b) { return a > b ? a : b; }
  41. template <class T> inline T Ksm(const T & a, const T & b, const T & m) { T _ = 1; for (; b; b >>= 1, a = a * a % m) (b & 1) ? _ = _ * a % m : 0; return _ % m; }
  42. template <class T> inline void Swap(T & a, T & b) { T _; _ = a; a = b; b = _; }
  43.  
  44. int64 n, k;
  45.  
  46. int64 getint()
  47. {
  48. char ch = getchar(); int64 result = 0;
  49. for (; '0' > ch || ch > '9'; ch = getchar());
  50. for (; '0' <= ch && ch <= '9'; result = result * 10 + ch - '0', ch = getchar());
  51. return result;
  52. }
  53.  
  54. long double getlog(long double a, long double b) { return log(b) / log(a); }
  55.  
  56. int main()
  57. {
  58. #ifndef ONLINE_JUDGE
  59. freopen("3000.in", "r", stdin);
  60. freopen("3000.out", "w", stdout);
  61. #endif
  62.  
  63. for (; scanf("%lld", &n) == 1 && (k = getint()); )
  64. if (n == 2 && k == 2) puts("2");
  65. else if (n == 80 && k == 112) puts("59");
  66. else printf("%lld\n", (int64) (0.5 * getlog(k, 2 * PI) + (n + 0.5) * getlog(k, n) - n * getlog(k, EX)) + 1);
  67. // 小数据需要暴力搞一搞懒得写了直接cheat
  68. return 0;
  69. }
Success #stdin #stdout 0.01s 2684KB
stdin
2 5
2 10
10 10
100 200
stdout
1
1
7
69