Created
August 25, 2022 05:09
-
-
Save EarthMessenger/53f2a5e99dcb766998603c3efbdbd697 to your computer and use it in GitHub Desktop.
calculate log2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define REPEAT0(x) x | |
#define REPEAT1(x) REPEAT0(x), REPEAT0(x) | |
#define REPEAT2(x) REPEAT1(x), REPEAT1(x) | |
#define REPEAT3(x) REPEAT2(x), REPEAT2(x) | |
#define REPEAT4(x) REPEAT3(x), REPEAT3(x) | |
#define REPEAT5(x) REPEAT4(x), REPEAT4(x) | |
#define REPEAT6(x) REPEAT5(x), REPEAT5(x) | |
#define REPEAT7(x) REPEAT6(x), REPEAT6(x) | |
#define REPEAT8(x) REPEAT7(x), REPEAT7(x) | |
#define REPEAT9(x) REPEAT8(x), REPEAT8(x) | |
#define REPEAT10(x) REPEAT9(x), REPEAT9(x) | |
#define REPEAT11(x) REPEAT10(x), REPEAT10(x) | |
#define REPEAT12(x) REPEAT11(x), REPEAT11(x) | |
#define REPEAT13(x) REPEAT12(x), REPEAT12(x) | |
#define REPEAT14(x) REPEAT13(x), REPEAT13(x) | |
#define REPEAT15(x) REPEAT14(x), REPEAT14(x) | |
#define REPEAT16(x) REPEAT15(x), REPEAT15(x) | |
#define REPEAT17(x) REPEAT16(x), REPEAT16(x) | |
#define REPEAT18(x) REPEAT17(x), REPEAT17(x) | |
#define REPEAT19(x) REPEAT18(x), REPEAT18(x) | |
#define LG1 0, 0 | |
#define LG2 LG1, REPEAT1(1) | |
#define LG3 LG2, REPEAT2(2) | |
#define LG4 LG3, REPEAT3(3) | |
#define LG5 LG4, REPEAT4(4) | |
#define LG6 LG5, REPEAT5(5) | |
#define LG7 LG6, REPEAT6(6) | |
#define LG8 LG7, REPEAT7(7) | |
#define LG9 LG8, REPEAT8(8) | |
#define LG10 LG9, REPEAT9(9) | |
#define LG11 LG10, REPEAT10(10) | |
#define LG12 LG11, REPEAT11(11) | |
#define LG13 LG12, REPEAT12(12) | |
#define LG14 LG13, REPEAT13(13) | |
#define LG15 LG14, REPEAT14(14) | |
#define LG16 LG15, REPEAT15(15) | |
#define LG17 LG16, REPEAT16(16) | |
#define LG18 LG17, REPEAT17(17) | |
#define LG19 LG18, REPEAT18(18) | |
#define LG20 LG19, REPEAT19(19) | |
const int lg2[] = { LG20 }; | |
int main() | |
{ | |
int n; | |
scanf("%d", &n); | |
printf("%d\n", lg2[n]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment