HDU 1788 Chinese remainder theorem again
2014-08-11 10:38
567 查看
题目链接
题意 : 中文题不详述。
思路 : 由N%Mi=(Mi-a)可得(N+a)%Mi=0;要取最小的N即找Mi的最小公倍数即可。
View Code
题意 : 中文题不详述。
思路 : 由N%Mi=(Mi-a)可得(N+a)%Mi=0;要取最小的N即找Mi的最小公倍数即可。
//1788 #include <cstdio> #include <cstring> #include <cmath> #include <iostream> #define LL long long using namespace std ; LL gcd(LL x,LL y) { return y == 0 ? x : gcd(y,x%y) ; } int main() { int I,a ; while(~scanf("%d %d",&I,&a)) { if(I == 0 && a == 0) break ; int x ; LL ans = 1; while(I--) { scanf("%d",&x) ; ans = (ans * x)/gcd(ans,x) ; } printf("%I64d\n",ans-a) ; } return 0 ; }
View Code
相关文章推荐
- Chinese remainder theorem again(hdu 1788)两种解法:线性同余方程或者简单的最小公倍数
- HDU 1788 Chinese remainder theorem again 中国剩余定理转换
- hdu 1788 Chinese remainder theorem again
- 【HDU】 1788 Chinese remainder theorem again
- Hdu 1788 Chinese remainder theorem again
- HDU——1788 Chinese remainder theorem again
- hdu 1788 Chinese remainder theorem again((数学:简单题)
- HDU 1788 Chinese remainder theorem again
- HDU 1788 Chinese remainder theorem again
- HDU1788 Chinese remainder theorem again 中国剩余定理
- hdu 1788 Chinese remainder theorem again
- HDU 1788——Chinese remainder theorem again
- 读控制台HDU 1788 Chinese remainder theorem again 数论读控制台
- hdu 1788 Chinese remainder theorem again(最小公倍数)
- hdu - 1788 - Chinese remainder theorem again-(gcd,不互质的中国剩余定理)
- hdu 1788 Chinese remainder theorem again(最小公倍数)
- hdu 1788 Chinese remainder theorem again
- Chinese remainder theorem again(HDU 1788)
- HDU1788 Chinese remainder theorem again【中国剩余定理】
- 【数论】 HDOJ 1788 Chinese remainder theorem again