zoukankan      html  css  js  c++  java
  • [洛谷P2613]【模板】有理数取余

    题目大意:给你$a,b(a,bleqslant10^{10001})$,求出$dfrac a bequiv1pmod{19260817}$,无解输出 Angry! 

    题解:在读入的时候取模,若$b=0$输出无解,否则正常的求逆就行了

    卡点:

    C++ Code:

    #include <cstdio>
    #include <cctype>
    const long long mod = 19260817;
    long long a, b;
    inline long long read() {
    	long long x;
    	char t = getchar();
    	while (isspace(t)) t = getchar();
    	for (x = t & 15, t = getchar(); isdigit(t); t = getchar()) x = (x * 10 + (t & 15)) % mod;
    	return x;
    }
    void exgcd(long long a, long long b, long long &x, long long &y) {
    	if (!b) x = 1, y = 0;
    	else exgcd(b, a % b, y, x), y -= a / b * x;
    }
    inline long long INV(long long a) {
    	long long x, y;
    	exgcd(a, mod, x, y);
    	if (x < 0) x += mod;
    	return x;
    }
    int main() {
    	a = read(), b = read();
    	if (!b) {
    		puts("Angry!");
    		return 0;
    	}
    	printf("%lld
    ", a * INV(b) % mod);
    	return 0;
    }
    

      

  • 相关阅读:
    css3 box-shadow
    JS的Document属性和方法
    简单配色方案web
    ps中参考线的使用技巧
    min-width() ie6
    js 模拟右键菜单
    display:table-cell
    js opener 的使用
    js的 new image()
    CSS 中文字体 Unicode 编码方案
  • 原文地址:https://www.cnblogs.com/Memory-of-winter/p/9692412.html
Copyright © 2011-2022 走看看