intfun(int n, int i, int j, int **a, int **op) { if (i == n) { return0; } if (op[i][j] != 0) return op[i][j];
op[i][j] = a[i][j] + max(fun(n, i + 1, j, a, op), fun(n, i + 1, j + 1, a, op)); return op[i][j]; }
voidFind_path(int **op, int **a, int n) { int j = 0; printf("路径如下:\n"); for (int i = 1; i < n; i++) { int node = op[i - 1][j] - a[i - 1][j]; if (node == op[i][j + 1]){ printf("%d", 2); j++; } else printf("%d", 1); } }
intmain() { int n; printf("Enter the size of the triangle: "); scanf("%d", &n);
int **data = (int **)malloc(sizeof(int *) * n); for (int i = 0; i < n; i++) { data[i] = (int *)malloc(sizeof(int) * n); }
for (int i = 0; i < n; i++) { for (int j = 0; j <= i; j++) { data[i][j] = 0; } }
FILE *file = fopen("out.txt", "r"); if (file == NULL) { fprintf(stderr, "Error opening the file.\n"); return1; }
for (int i = 0; i < n; i++) { for (int j = 0; j <= i; j++) { fscanf(file, "%d", &data[i][j]); } } fclose(file);
int **op = (int **)malloc(sizeof(int *) * n); for (int i = 0; i < n; i++) { op[i] = (int *)malloc(sizeof(int) * n); } for (int x = 0; x < n; x++) { for (int y = 0; y < n; y++) op[x][y] = 0; }
int result = fun(n, 0, 0, data, op); printf("最大路径是:%d\n", result); Find_path(op, data, n); system("pause"); return0; }
n=27814334728135671995890378154778822687713875269624843122353458059697288888640572922486287556431241786461159513236128914176680497775619694684903498070577307810263677280294114135929708745988406963307279767028969515305895207028282193547356414827419008393701158467818535109517213088920890236300281646288761697842280633285355376389468360033584102258243058885174812018295460196515483819254913183079496947309574392848378504246991546781252139861876509894476420525317251695953355755164789878602945615879965709871975770823484418665634050103852564819575756950047691205355599004786541600213204423145854859214897431430282333052121 c=456221314115867088638207203034494636244706611111621723577848729096069230067958132663018625661447131501758684502639383208332844681939698124459188571813527149772292464139530736717619741704945926075632064072125361516435631121845753186559297993355270779818057702973783391589851159114029310296551701456748698914231344835187917559305440269560613326893204748127999254902102919605370363889581136724164096879573173870280806620454087466970358998654736755257023225078147018537101 m_high=9999900281003357773420310681169330823266532533803905637 m_high <<= 128 e = 5
R.<x> = PolynomialRing(Zmod(n)) m = m_high + x f = m^e - c f = f.monic()
x = f.small_roots(X = 2^208,beta = 0.4) if x: m = m_high + x[0] print(long_to_bytes(int(m)))
backpack
attachment.py
from Crypto.Util.number import * import random from secret import flag a=[getPrime(32) for _ inrange(20)] p=random.getrandbits(32) assertlen(bin(p)[2:])==32 bag=0 for i in a: temp=p%2 bag+=temp*i p=p>>1
Ge = Ge.stack(Ge_last_row) Ge = Ge.augment(Ge_last_col)
X = Ge.LLL()[-1] X = X[:-1]
p = "" for i in X: ifabs(i) == 1: p += "1" ifabs(i) == 0: p += "0" print(p) m = int(p,2) ^^ enc print(m) flag = bytes.fromhex(hex(int(m))[2:]) print(flag)
非预期:
from Crypto.Util.number import long_to_bytes enc=871114172567853490297478570113449366988793760172844644007566824913350088148162949968812541218339 print(long_to_bytes(enc))
p = 14213355454944773291 q = 61843562051620700386348551175371930486064978441159200765618339743764001033297 c = 105002138722466946495936638656038214000043475751639025085255113965088749272461906892586616250264922348192496597986452786281151156436229574065193965422841 gift = 9751789326354522940
n = p**4*q d = gmpy2.invert(65537,p-1) temp = pow(gift,d,p) e = temp - 114514 res = Zmod(n)(c).nth_root(e, all=True)
for m in res: flag = long_to_bytes(int(m)) ifb"hgame"in flag: print(flag) break