hdu 1788 Chinese remainder theorem again((数学:简单题)
2014-07-14 17:05
357 查看
看到题目名字以及题目描述上来就写了中国剩余定理
毫无疑问的WA了,因为我写的是n[i]互质版本的
但是题目中并没有说两两互质
百度之后发现这个题是个水题...
0ms代码如下:
毫无疑问的WA了,因为我写的是n[i]互质版本的
但是题目中并没有说两两互质
百度之后发现这个题是个水题...
0ms代码如下:
#include <stdio.h> #define LL long long LL gcd(LL a, LL b) { return b==0 ? a : gcd(b, a%b); } int main(void) { LL n, a, m, ans; while(scanf("%I64d%I64d", &n, &a) && (n+a)) { ans = 1; while(n--) { scanf("%I64d", &m); ans = ans*m/gcd(ans, m); } printf("%I64d\n", ans-a); } }
相关文章推荐
- 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
- 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 中国剩余定理
- HDU1788 Chinese remainder theorem again【中国剩余定理】
- HDU——1788 Chinese remainder theorem again
- hdu - 1788 - Chinese remainder theorem again-(gcd,不互质的中国剩余定理)
- hdu 1788 Chinese remainder theorem again
- hdoj-1788-Chinese remainder theorem again