Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdint.h>
- #define mod 1000333
- unsigned long fib(uint64_t param)
- {
- if (param == 1 || param == 2) {
- return 1;
- } else {
- return (fib(param - 1) + fib(param - 2)) % mod;
- }
- }
- unsigned long cmmdc(unsigned long first, unsigned long second)
- {
- unsigned long last;
- while (second) {
- last = first % second;
- first = second;
- second = last;
- }
- return first;
- }
- int main()
- {
- freopen("fibgcd.in", "rt", stdin);
- freopen("fibgcd.out", "wt", stdout);
- uint64_t n, m;
- scanf("%I64u %I64u", &n, &m);
- printf("%lu", cmmdc(fib(n), fib(m)));
- fclose(stdin);
- fclose(stdout);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement