LA 4270 离散平方根
来源:互联网 发布:小米3可以用4g网络吗 编辑:程序博客网 时间:2024/05/16 14:50
#include<cstdio>#include<cstring>#include<algorithm>typedef long long LL;using namespace std;LL X,n,r;void exgcd(LL a,LL b,LL &d,LL &x,LL &y){if(b==0){d=a;x=1;y=0;}else{exgcd(b,a%b,d,y,x);y-=(a/b)*x;}}LL res[100000],cnt;void add(LL a,LL b){LL c=2*r,d,x,y,t;exgcd(a,b,d,x,y);if(c%d==0){x*=c/d,y*=c/d;t=a/d;for(int i=y%t;i*b-r<n;i+=t)if(i*b-r>=0&&(i*b-r)*(i*b-r)%n==X) res[cnt++]=i*b-r;}}void solve(){cnt=1;res[0]=r;for(int i=1;i*i<=n;i++){if(n%i==0){add(i,n/i); add(n/i,i);}}sort(res,res+cnt);cnt=unique(res,res+cnt)-res;for(int i=0;i<cnt;i++)printf(" %lld",res[i]);printf("\n");}int main(){int t=1;while(~scanf("%lld%lld%lld",&X,&n,&r)&&(n+X+r)){printf("Case %d:",t++);solve();}}
阅读全文
0 0
- LA 4270 离散平方根
- LA 2572 Viva Confetti 离散化 *
- 平方根
- [平方根]
- 平方根
- la la la, la la la
- World Final 2008 ,LA 4127 The Sky is the Limit 离散化
- LA 6663 —— Count the Regions(连通分量 + 离散化)
- LA 4270 Discrete Square Roots
- 离散
- 离散
- 离散
- 离散
- 求平方根
- 近似平方根
- 整数平方根
- 大数 平方根
- 迭代求平方根
- webpack-dev-server使用方法,看完还不会的来找我~
- 苹果新增处罚方式,大量被拒 App 审核周期延长一周以上
- IOS调取摄像头和相册并保存图片
- 1954-节奏大师
- 白话经典算法系列之三 希尔排序的实现
- LA 4270 离散平方根
- C语言结构体对象间直接赋值
- tomcat启动报错ClassNotFoundExceptiion:org.springframework.web.context.ContextLoaderListener
- Android 命名规范 (提高代码可以读性)
- BZOJ 2206 缩圈+拓扑[tarjan模板]
- 数学 | 推理 | 思维 | 打表 | 找规律 | 贪心 | 暴力
- CC2640R2F BLE5.0 蓝牙协议栈信道选择算法#2(CSA#2)
- canvas实现一颗树的生长到开花
- td百分比显示内容过多以点号(...)显示