有点小郁闷的~
Accepted | 1797 | C++ | 00:00.00 | 388K |
#include<stdio.h>
#include <stdlib.h>
#include <string.h>
int gcd(int a, int b)
{
int ret = a;
while(b > 0 )
ret = b, b = a % b, a = ret;
return ret;
}
void solve(int m)
{
int n[2 ];
scanf("%d", &n[0 ]);
for(int i = 1; i < m; i++ )
{
int j = i & 1 ;
scanf("%d", & n[j]);
//n[0] * n[1] / gcd(n[0], n[1]会溢出的,汗一个~ ~||
n[j] = n[0] / gcd(n[0], n[1]) * n[1 ];
}
printf("%d ",n[(m - 1) & 1 ]);
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("1797.txt", "r" , stdin);
#endif
int t, m;
while(scanf("%d", &t) != EOF)
while(scanf("%d", &m) != EOF)
solve(m);
#ifndef ONLINE_JUDGE
fclose(stdin);
#endif
}
#include <stdlib.h>
#include <string.h>
int gcd(int a, int b)
{
int ret = a;
while(b > 0 )
ret = b, b = a % b, a = ret;
return ret;
}
void solve(int m)
{
int n[2 ];
scanf("%d", &n[0 ]);
for(int i = 1; i < m; i++ )
{
int j = i & 1 ;
scanf("%d", & n[j]);
//n[0] * n[1] / gcd(n[0], n[1]会溢出的,汗一个~ ~||
n[j] = n[0] / gcd(n[0], n[1]) * n[1 ];
}
printf("%d ",n[(m - 1) & 1 ]);
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("1797.txt", "r" , stdin);
#endif
int t, m;
while(scanf("%d", &t) != EOF)
while(scanf("%d", &m) != EOF)
solve(m);
#ifndef ONLINE_JUDGE
fclose(stdin);
#endif
}