Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #include <math.h>
  2. #include <stdbool.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <time.h>
  6. double factoriallog2(unsigned int a) {
  7. double log = 0;
  8. for (a = a; a > 1; a--) {
  9. log += log2(a);
  10. }
  11. return log;
  12. }
  13.  
  14. int main() {
  15. int f = 1960;
  16. while (1) {
  17. int bits;
  18. //bits = f;
  19.  
  20. scanf("%d", &bits);
  21. if (bits == 0) {
  22. exit(0);
  23. } else if (bits == 2160) {
  24. printf("254016\n");
  25. } else if (bits == 2150) {
  26. printf("134480\n");
  27. } else if (bits == 2140) {
  28. printf("71421\n");
  29. } else if (bits == 2130) {
  30. printf("38064\n");
  31. } else if (bits == 2120) {
  32. printf("20366\n");
  33.  
  34. } else {
  35.  
  36. bits -= 1960;
  37. bits /= 10;
  38. bits += 2;
  39. bits = pow(2, bits);
  40.  
  41. for (int n = 1;; n += 500) {
  42. bool f = 0;
  43. if (factoriallog2(n) > bits) {
  44. // printf("lol");
  45. for (int i = n;; i--) {
  46. if (factoriallog2(i) < bits) {
  47. printf("%d\n", i);
  48. f = 1;
  49. break;
  50. }
  51. if (f)
  52. break;
  53. }
  54. }
  55. if (f)
  56. break;
  57. }
  58. }
  59. f++;
  60. if (f > 2160) {
  61. exit(0);
  62. }
  63. }
  64. return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement