Skip to content

Instantly share code, notes, and snippets.

@potetisensei
Last active August 29, 2015 14:23
Show Gist options
  • Save potetisensei/973772f7a84b56f3fa5f to your computer and use it in GitHub Desktop.
Save potetisensei/973772f7a84b56f3fa5f to your computer and use it in GitHub Desktop.
Internet Problem Solving Contest 2015 J2
#include <cstdio>
bool check(unsigned short ax, unsigned short bx) {
unsigned short tmp;
for (int i=0; i<23; i++) {
if (bx < ax) return false;
if (ax == 0) return false;
bx -= ax;
tmp = ax;
ax = bx;
bx = tmp;
}
return true;
}
int main() {
for (unsigned int a=0xffff; a>=0; a--) {
for (unsigned int b=a; b<=a*2 && b<=0xffff; b++) {
if (check((unsigned short)a, (unsigned short)b)) printf("%u %u\n", a, b);
}
if (a == 0) break;
}
}
ax = 28657
bx = 46368
cx = 0x27
s = ";M\xb3\xfcd\x89\xdc\x0cz\xa2\xe6U\xca\xd1wm\xaf\x04[\x84\xe4q \x97&E\xba\xe4^\x86\xcd1C\xa0\rR\x86\xf2p\r\n$"
i = 0
ans = ""
while cx != 0:
ans += chr(ord(s[i]) ^ (ax/0x100))
ax += bx
ax %= 0x10000
i += 1
cx -= 1
print ans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment