-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmonstro.cpp
More file actions
84 lines (69 loc) · 1.32 KB
/
monstro.cpp
File metadata and controls
84 lines (69 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//#define _GLIBCXX_USE_CXX11_ABI 1
#include <limits>
#include <cstdint>
#include <cinttypes>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <string>
#include <algorithm>
int test(const int c,int n);
int main(int ac,char **ap)
{
const std::vector<std::string> ops
{
"n++;",
"n--;",
"n+=c;",
"n-=c;",
"n<<=(c&3);",
"n>>=(c&3);",
"n^=c;",
"n%=c;",
"n*=c;",
"n/=c;",
"n|=c;",
"n&=c;"
};
const std::vector<int> idx{0,1,2,3,4,5,6,7,8};//,9,10,11};
{
int f=0;
std::vector<int> i=idx;
do
{
std::printf("int f_%08x(const int c, int n){",f);
for (auto &n : i)
{
std::printf("%s",ops[n].c_str());
}
std::printf("return n;};\n");
++f;
}
while (std::next_permutation(i.begin(),i.end()));
}
{
int f=0;
std::vector<int> i=idx;
std::printf("#include <cstdlib>\n#include <ctime>\n#include <cstdio>\n");
std::printf("int main(){"
"std::srand(std::time(nullptr));"
"const int c=std::rand();"
"int n=std::rand();"
"\n"
);
do
{
std::printf("n=f_%08x(c,n);\n",f);
++f;
}
while (std::next_permutation(i.begin(),i.end()));
std::printf("std::printf(\"%%d\",n);\nreturn 0;}"
);
}
// std::srand(std::time(nullptr));
// int n=std::rand();
// std::printf("\n%d\n",r);
// return test(r);
return 0;
}