【数论】Disgruntled Judge, NWERC 2008, UVa12169
来源:互联网 发布:人工智能需要哪些技术 编辑:程序博客网 时间:2024/06/05 16:55
#include<bits/stdc++.h>#define mod 10001using namespace std;typedef long long LL;LL n,p[210];void exgcd(LL a,LL b,LL& d,LL& x,LL& y){ if(!b) d=a,x=1,y=0; else exgcd(b,a%b,d,y,x),y-=x*(a/b);}int main(){ios::sync_with_stdio(false);cin>>n;for(int i=1;i<n*2;i+=2)cin>>p[i];for(LL a=0;;a++){LL k,b,d;LL t = (p[3]-a*a*p[1]);exgcd(mod,a+1,d,k,b);if(t%d)continue;//无解b = b*t/d;bool ok = true;for(int i=2;i<=2*n;i++){if(i&1){if(p[i]!=((a*p[i-1]+b)%mod)){ok = false;break;}}else{p[i]=(a*p[i-1]+b)%mod;}}if(ok)break;}for(int i=2;i<=2*n;i+=2)cout<<p[i]<<endl;return 0;}
0 0
- 【数论】Disgruntled Judge, NWERC 2008, UVa12169
- 【数论】[Uva12169]Disgruntled Judge
- 扩展欧几里得应用解不定方程(uva12169,Disgruntled Judge,NWERC 2008)
- 【NWERC2008】uva12169 Disgruntled Judge
- UVa12169 - Disgruntled Judge(模运算)
- UVa12169 - Disgruntled Judge (扩展欧几里得)
- UVa12169 - Disgruntled Judge(模运算、拓展欧几里得)
- 例题10-2 UVa12169 Disgruntled Judge(拓展欧几里德)
- UVA 12169 - Disgruntled Judge
- 12169 - Disgruntled Judge
- uva 12169 Disgruntled Judge
- UVA - 12169 Disgruntled Judge
- UVa 12169 Disgruntled Judge
- Disgruntled Judge UVA
- Disgruntled Judge UVA
- Disgruntled Judge UVA
- Disgruntled Judge UVA
- Disgruntled Judge UVA
- dfs题:C - Prime Ring Problem
- 欢迎使用CSDN-markdown编辑器
- 排序算法再回顾
- Netty详解一(理解Netty的设计理念)
- leetcode 2. Add Two Numbers python实现的理解,结点,单链表的应用,大数,进位的问题
- 【数论】Disgruntled Judge, NWERC 2008, UVa12169
- UVA 11292 The Dragon of Loowater
- mysql中创建数据库并授权
- MPI并行计算与矩阵1
- UVA 1421 Archery(二分+维护区间)
- 网站被攻击常见的几种方式
- codeforces 724B Batch Sort
- Java基础复习---字符串
- imread函数、namedWindow函数、imshow函数、imwrite函数