Skip to content
Snippets Groups Projects
Commit 2c3504c7 authored by Fernando K's avatar Fernando K
Browse files

Caderno versão final

parent 0e33afa7
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -344,11 +344,16 @@ para $a$ e $m$ coprimos.
\item $10^6 + 69$
\item $10^9 + 7$
\item $10^9 + 9$
\item $10^9 + 21$
\item $10^{18}-11$
\item $10^{18}+3$
\item $2^{61}-1$
\item $1000696969$
\item $998244353$
\item $998244353$ (\texttt{(119<<23)+1})
\item $880803841$ (\texttt{(105<<23)+1})
\item $754974721$ (\texttt{(45<<24)+1})
\item $469762049$ (\texttt{(7<<26)+1})
\item $167772161$ (\texttt{(5<<25)+1})
\end{itemize}
\end{multicols}
......@@ -359,7 +364,7 @@ para $a$ e $m$ coprimos.
\subsection{Teste de estresse}
\lstinputlisting[language=bash]{fontes-com-hash/stress.sh}
\subsection{Hash da entrada padrão}
\lstinputlisting[language=bash]{fontes-com-hash/hash.sh}
\lstinputlisting[language=bash]{fontes-com-hash/hash.py}
\subsection{vimrc}
\lstinputlisting{fontes-com-hash/vimrc}
\subsection{Gerador}
......
fontes/1 0 → 100644
import subprocess as sp, hashlib as hl, sys
process = lambda a: (a[0], ''.join(sp.run(['cpp', '-dD', '-P', '-fpreprocessed'],
input=a[1], text=True, capture_output=True).stdout.split()))
l, s = list(map(process, enumerate(sys.stdin))), []
for i, line in l:
for c in l[i]:
if c == '{': s.append(i)
elif c == '}': lp = s[-1]; s.pop()
print(hl.md5((process(' '.join(l[lp:][1])).encode()
if l[i] == '}' or l[i] == '};' else l[i][1].encode())).hexdigest()[0:3]
if l[i] else '', line[:-1])
mt19937 rnd;
ll gen(ll a, ll b) {
uniform_int_distribution<ll> dist (a, b);
return dist(rnd);
}
mt19937 rnd; ll gen(ll a, ll b) {
uniform_int_distribution<ll> dist (a, b); return dist(rnd); }
int main(int argc, char* argv[]) {
if (argc < 2) {
cerr << "usage: " << argv[0] << " <seed>\n"; return 1;
}
cerr << "usage: " << argv[0] << " <seed>\n"; return 1; }
rnd = mt19937(atoi(argv[1]));
}
import subprocess as sp, hashlib as hl, sys
p = lambda a: ''.join(
sp.run(['cpp', '-dD', '-P', '-fpreprocessed'],
input=a, text=True, capture_output=True).stdout.split())
l, s = [], []
for i, line in enumerate(sys.stdin):
l.append(p(line))
for c in l[i]:
if c == '{': s.append(i)
elif c == '}': lp = s[-1]; s.pop()
print(hl.md5((p(' '.join(l[lp:])).encode()
if l[i] == '}' or l[i] == '};'
else l[i].encode())).hexdigest()[0:3]
if l[i] else '', line[:-1])
for (( I=0; I < 5; I++ )); do
./gen $I >t.in
./brute <t.in >t.exp
./a.out <t.in >t.out
./gen $I >t.in; ./brute <t.in >t.exp; ./a.out <t.in >t.out
if diff -u t.exp t.out; then : ; else
echo "--> entrada:"; cat t.in
echo "--> saída esperada"; cat t.exp
echo "--> saída obtida"; cat t.out
break
fi
echo "--> saída obtida"; cat t.out; break; fi
echo -n .
done
#include <bits/stdc++.h>
using namespace std; using ll = long long;
#define all(X) begin(X), end(X)
int main() {
cin.tie(0)->sync_with_stdio(0);
}
int main() { cin.tie(0)->sync_with_stdio(0); }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment