Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* a289 */
- /* AC (0.1s, 88KB) */
- #include <cstdio>
- using namespace std;
- typedef long long int64;
- int64 x, y, a, b;
- int64 exgcd(int64 a, int64 b)
- {
- if(b == 0)
- {
- x = 1;
- y = 0;
- return a;
- }
- int64 r = exgcd( b, a % b );
- int64 tmp = x;
- x = y;
- y = tmp - a / b * y;
- return r;
- }
- int main()
- {
- while(~scanf("%lld %lld", &a, &b))
- if(b != 1 && exgcd(a, b) == 1)
- printf("%lld\n", (x % b + b) % b);
- else
- puts("No Inverse");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement