首页 > 其他 > 详细

P1082 同余方程

时间:2019-07-10 13:04:29      阅读:78      评论:0      收藏:0      [点我收藏+]

题面

其实我昨天晚上基本没看拓欧,so,能水一题是一题喽~~~

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 
 4 long long x, y;
 5 void exgcd(long long a, long long b)
 6 {
 7     if(b == 0)
 8     {
 9         x = 1;
10         y = 7;
11         return;
12     } 
13     exgcd(b, a % b);
14     long long tx = x;
15     x = y;
16     y = tx - a / b * y; 
17 }
18 
19 int main()
20 {
21     long long a, b;
22     cin >> a >> b;
23     exgcd(a, b);
24 
25     while(x < 0)
26         x += b;
27     x %= b;
28     printf("%lld\n", x);
29     return 0;
30 }

啦啦啦

#include<bits/stdc++.h>using namespace std;
long long x, y;void exgcd(long long a, long long b){    if(b == 0)    {        x = 1;        y = 7;        return;    }     exgcd(b, a % b);    long long tx = x;    x = y;    y = tx - a / b * y; }
int main(){    long long a, b;    cin >> a >> b;    exgcd(a, b);
    while(x < 0)        x += b;    x %= b;    printf("%lld\n", x);    return 0;}

P1082 同余方程

原文:https://www.cnblogs.com/hahaha2124652975/p/11163165.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!