// 14-2
#include <stdio.h>
int gcm(int x, int y);
int main()
{
int x, y, g;
if (x * y == 0) {
return 1;
}
g = gcm(x, y);
if (g < 0) {
g = -g;
}
printf("%d gcm %d = %d\n", x
, y
, g
); return 0;
}
int gcm(int x, int y)
{
int z;
while ((z = x % y)) {
x = y;
y = z;
}
return y;
}
Ly8gMTQtMgojaW5jbHVkZSA8c3RkaW8uaD4KCmludCBnY20oaW50IHgsIGludCB5KTsKCmludCBtYWluKCkKewogICAgaW50IHgsIHksIGc7CiAgICBwcmludGYoIu+8keOBpOebruOBruWApOOCkuWFpeWKm1xuIik7c2NhbmYoIiVkIiwgJngpOwogICAgcHJpbnRmKCLvvJLjgaTnm67jga7lgKTjgpLlhaXliptcbiIpO3NjYW5mKCIlZCIsICZ5KTsKICAgIGlmICh4ICogeSA9PSAwKSB7CiAgICAgICAgcHJpbnRmKCLjgrzjg63jgpLmjIflrprjgZfjgarjgYTjgafjgY/jgaDjgZXjgYRcbiIpOwogICAgICAgIHJldHVybiAxOwogICAgfQogICAgZyA9IGdjbSh4LCB5KTsKICAgIGlmIChnIDwgMCkgewogICAgICAgIGcgPSAtZzsKICAgIH0KICAgIHByaW50ZigiJWQgZ2NtICVkID0gJWRcbiIsIHgsIHksIGcpOwogICAgcmV0dXJuIDA7Cn0KCmludCBnY20oaW50IHgsIGludCB5KQp7CiAgICBpbnQgejsKICAgIHdoaWxlICgoeiA9IHggJSB5KSkgewogICAgICAgIHggPSB5OwogICAgICAgIHkgPSB6OwogICAgfQogICAgcmV0dXJuIHk7Cn0=