她
来源:互联网 发布:哪个软件可以听课 编辑:程序博客网 时间:2024/04/27 17:31
前30暴力枚举,特判无解情况。
再20 L==R,变为解同余方程
#include <cstdio>#include <iostream>#define LL long longusing namespace std;long long x,y;long long gcd(long long a,long long b){ if(!b) return a; return gcd(b,a%b);}LL e_gcd(LL a,LL b,LL &x,LL &y) { if(b==0) { x=1; y=0; return a; } LL ans=e_gcd(b,a%b,x,y); LL temp=x; x=y; y=temp-a/b*y; return ans; } LL cal(LL a,LL b,LL c) { LL x,y; LL gcd=e_gcd(a,b,x,y);printf("%d ",x); if(c%gcd!=0) return -1; x*=c/gcd; b/=gcd; if(b<0) b=-b; LL ans=x%b; if(ans<=0) ans+=b; return ans; } int main(){ long long t; scanf("%lld",&t); for(int i=1;i<=t;i++) { long long l,r,s,m; scanf("%lld%lld%lld%lld",&m,&s,&l,&r); /*if(l>r||s%m==0||l>=m) { printf("-1\n"); continue; }*/ if(l==r) { printf("%lld\n",cal(s,m,r)); continue; } for(long long j=1;;j++) { if((j*s)%m>=l&&(j*s)%m<=r) { printf("%lld\n",j); break; } } }}
阅读全文
1 0
- 她...
- 她
- 她~~
- 她
- 她
- 她
- 她
- 她。
- 她
- 她
- 她
- 她
- 她
- 她和她!!!
- 爱她就包容她呵护她
- 告诉她
- 还是她
- 她很好
- 移动架构14_命令模式
- numpy.unravel_index
- #POJ1475#Pushing Boxes(A*_搜索)
- git如何上传文件到github
- Codeforces Round #438 C.Qualification Rounds(状态压缩再枚举状态)
- 她
- OpenCV批量读取路径下所有图片
- 对英文字母按照不区分大小写进行排序
- [python]leetcode(309). Best Time to Buy and Sell Stock with Cooldown
- 10.6 句子 2409
- 深入理解Java:注解(Annotation)--注解处理器
- mongoose的基础用法
- 从零学习JAVA多线程(一):认识多线程
- Java: 变量声明在循环体内还是循环体外的争论