#include\x20\x3cstdlib.h\x3e #include\x20\x3cstdio.h\x3e #include\x20\x3cpthread.h\x3e

#define\x20FLAG_LEN\x2020

void\x20*\x20checking(void\x20arg)\x20{ \x20\x20char\x20result\x20=\x20malloc(sizeof(char)); \x20\x20char\x20argument\x20=\x20(char\x20)arg; \x20\x20*result\x20=\x20(argument[0]+argument[1])\x20^\x20argument[2]; \x20\x20return\x20result; }

int\x20highly_optimized_parallel_comparsion(char\x20*user_string) { \x20\x20int\x20initialization_number; \x20\x20int\x20i; \x20\x20char\x20generated_string[FLAG_LEN\x20+\x201]; \x20\x20generated_string[FLAG_LEN]\x20=\x20'\x00';

\x20\x20while\x20((initialization_number\x20=\x20random())\x20>=\x2064); \x20\x20 \x20\x20int\x20first_letter; \x20\x20first_letter\x20=\x20(initialization_number\x20%\x2026)\x20+\x2097;

\x20\x20pthread_t\x20thread[FLAG_LEN]; \x20\x20char\x20differences[FLAG_LEN]\x20=\x20{0, -11, -9, -1, 13, -13, -4, -11, -9, -1, -7, 6, -13, 13, 3, 9, -13, -11, 6, -7}; \x20\x20char\x20arguments[20]; \x20\x20for\x20(i\x20=\x200; i\x20<\x20FLAG_LEN; i++)\x20{ \x20\x20\x20arguments[i]\x20=\x20(char\x20)malloc(3*sizeof(char)); \x20\x20\x20arguments[i][0]\x20=\x20first_letter; \x20\x20\x20arguments[i][1]\x20=\x20differences[i]; \x20\x20\x20arguments[i][2]\x20=\x20user_string[i];

\x20\x20\x20pthread_create((pthread_t*)(thread+i), NULL, checking, arguments[i]); \x20\x20}

\x20\x20void\x20result; \x20\x20int\x20just_a_string[FLAG_LEN]\x20=\x20{115, 116, 114, 97, 110, 103, 101, 95, 115, 116, 114, 105, 110, 103, 95, 105, 116, 95, 105, 115}; \x20\x20for\x20(i\x20=\x200; i\x20<\x20FLAG_LEN; i++)\x20{ \x20\x20\x20pthread_join((thread+i), &result); \x20\x20\x20generated_string[i]\x20=\x20*(char\x20*)result\x20+\x20just_a_string[i]; \x20\x20\x20free(result); \x20\x20\x20free(arguments[i]); \x20\x20}

\x20\x20int\x20is_ok\x20=\x201; \x20\x20for\x20(i\x20=\x200; i\x20<\x20FLAG_LEN; i++)\x20{ \x20\x20\x20if\x20(generated_string[i]\x20!=\x20just_a_string[i]) \x20\x20\x20\x20return\x200; \x20\x20}

\x20\x20return\x201; }

int\x20main() { \x20\x20char\x20user_string\x20=\x20(char\x20)calloc(FLAG_LEN+1, sizeof(char)); \x20\x20fgets(user_string, FLAG_LEN+1, stdin); \x20\x20int\x20is_ok\x20=\x20highly_optimized_parallel_comparsion(user_string); \x20\x20if\x20(is_ok) \x20\x20\x20printf("You\x20win!\n"); \x20\x20else \x20\x20\x20printf("Wrong!\n"); \x20\x20return\x200;


原文地址: https://www.cveoy.top/t/topic/pXE5 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录