Compare commits
2 Commits
920f830fac
...
0a03bc557b
| Author | SHA1 | Date | |
|---|---|---|---|
| 0a03bc557b | |||
| 282d55c3cd |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -11,8 +11,5 @@ lib/
|
||||
GPATH
|
||||
GRTAGS
|
||||
GTAGS
|
||||
FOO*
|
||||
BAR*
|
||||
QUAX*
|
||||
TOTO*
|
||||
README.html
|
||||
compile_commands.json
|
||||
|
||||
31
2020/day25/ex1-c.c
Normal file
31
2020/day25/ex1-c.c
Normal file
@@ -0,0 +1,31 @@
|
||||
/* ex1-c: Advent2020, day 25/part 1
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(ac, av)
|
||||
int ac;
|
||||
char **av;
|
||||
{
|
||||
ulong pub[] = {1, 1}, enc[] = {1, 1}, key[2], res;
|
||||
|
||||
scanf("%lu", key);
|
||||
scanf("%lu", key+1);
|
||||
while (1) {
|
||||
pub[0] = pub[0] * 7 % 20201227;
|
||||
pub[1] = pub[1] * 7 % 20201227;
|
||||
enc[0] = enc[0] * key[0] %20201227;
|
||||
enc[1] = enc[1] * key[1] %20201227;
|
||||
if (pub[0] == key[0]) {
|
||||
res=enc[1];
|
||||
break;
|
||||
} else if (pub[1] == key[1]) {
|
||||
res=enc[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
printf("%s : res=%lu\n", *av, res);
|
||||
exit (0);
|
||||
}
|
||||
Reference in New Issue
Block a user