标签:scan pre def main printf pac code long lld
水题,扩展欧几里得求解即可
错误原因:扩展欧几里得写炸
#include<cstdio> #include<cmath> using namespace std; typedef long long LL; LL x,y; LL a,b; LL exgcd(LL a,LL b) { if(b==0) { x=1;y=0; return a; } else { LL t1=exgcd(b,a%b),t=x; x=y; y=t-a/b*y; return t1; } } int main() { scanf("%lld%lld",&a,&b); if(exgcd(a,b)==1) { LL t1=floor(-(double)x/b)+1; printf("%lld",t1*b+x); } return 0; }
标签:scan pre def main printf pac code long lld
原文地址:http://www.cnblogs.com/hehe54321/p/7789012.html