标签:意思 printf mod several i++ cat line ast int
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1019
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 61592 Accepted Submission(s): 23486
#include<bits/stdc++.h> using namespace std; typedef long long LL; int gcd(int a,int b) { if (b==0) return a; return gcd(b, a%b); } int main() { //公式:a,b的最小公倍数等于a,b的乘积除以a,b的最大公约数 //直接暴力即可 int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); int a=1,cnt=1; int x; for(int i=0;i<n;i++) { scanf("%d",&x); cnt=a/gcd(a,x)*x;//先除后乘,避免溢出 a=cnt; } printf("%d\n",a); } return 0; }
标签:意思 printf mod several i++ cat line ast int
原文地址:https://www.cnblogs.com/yinbiao/p/9313387.html