hdu 1019 最小公倍数
时间:2014-07-22 23:06:34
收藏:0
阅读:311
简单题 注意__int64 的使用
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 |
Problem : 1019 ( Least Common Multiple ) Judge Status : Accepted RunId : 10599776 Language : C++ Author : xiaoniuwin Code Render Status : Rendered By HDOJ C++ Code Render Version 0.01 Beta #include<iostream> using
namespace std; __int64
f( __int64
a, __int64
b) { __int64
t; __int64
sum=a*b; if (a<b) { t=a; a=b; b=t; } while (b) { t=a%b; a=b; b=t; } return
sum/a; } int
main() { int
t,n; __int64
x; __int64
lcm; scanf ( "%d" ,&t); while (t--) { scanf ( "%d" ,&n); scanf ( "%I64d" ,&lcm); n--; while (n--) { scanf ( "%I64d" ,&x); lcm=f(lcm,x); } printf ( "%I64d\n" ,lcm); } return
0; } |
评论(0)