hdu 2028我测试正确,为什么提示wrong answer啊?
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/13 04:37:21
hdu 2028我测试正确,为什么提示wrong answer啊?
求n个数的最小公倍数.
最后输入32位整数怎么实现啊?
Input
输入包含多个测试实例,每个测试实例的开始是一个正整数n,然后是n个正整数.
Output
为每组测试数据输出它们的最小公倍数,每个测试实例的输出占一行.你可以假设最后的输出是一个32位的整数.
Sample Input
2 4 6
3 2 5 7
Sample Output
12
70
我的代码:
#include
main()
{
long n,i,k,t,r,p,max;
long a[100];
while(scanf("%d",&n)!=EOF)
{
max=1;
for(i=1;i
求n个数的最小公倍数.
最后输入32位整数怎么实现啊?
Input
输入包含多个测试实例,每个测试实例的开始是一个正整数n,然后是n个正整数.
Output
为每组测试数据输出它们的最小公倍数,每个测试实例的输出占一行.你可以假设最后的输出是一个32位的整数.
Sample Input
2 4 6
3 2 5 7
Sample Output
12
70
我的代码:
#include
main()
{
long n,i,k,t,r,p,max;
long a[100];
while(scanf("%d",&n)!=EOF)
{
max=1;
for(i=1;i
你的思路有点没明白,但你的max 有可能会超范围;
说下我的思路:a * b / a 和 b 的最大公约数 = a 和 b 的最小公倍数
a, b, c的最小公倍数 = (a b) 的最小公倍数 和 c 的最小公倍数
我的代码:
#include
int gcd (int a, int b);
int main ()
{
int i;
int n;
int a, value, temp;
while (scanf ("%d", &n) == 1)
{
value = 1;
for (i = 0; i < n; i ++)
{
scanf ("%d", &a);
temp = gcd (value, a);
value = value / temp * a;
}
printf ("%d\n", value);
}
return 0;
}
int gcd (int a, int b)
{
if (a % b != 0)
{
return gcd (b, a % b);
}
return b;
}
说下我的思路:a * b / a 和 b 的最大公约数 = a 和 b 的最小公倍数
a, b, c的最小公倍数 = (a b) 的最小公倍数 和 c 的最小公倍数
我的代码:
#include
int gcd (int a, int b);
int main ()
{
int i;
int n;
int a, value, temp;
while (scanf ("%d", &n) == 1)
{
value = 1;
for (i = 0; i < n; i ++)
{
scanf ("%d", &a);
temp = gcd (value, a);
value = value / temp * a;
}
printf ("%d\n", value);
}
return 0;
}
int gcd (int a, int b)
{
if (a % b != 0)
{
return gcd (b, a % b);
}
return b;
}
hdu 2028我测试正确,为什么提示wrong answer啊?
hdu 为什么总是wrong answer哪
HDU 1003,wrong answer
hdu2044为什么wrong answer 啊.
为什么一直是Wrong Answer啊,
hdu 1002 A + B Problem II 一直wrong answer,请高手看看哪错了
acm题,wrong answer,为什么?
hdu 1011那位大牛能帮我看看代码 为什么总是wa啊?感激不尽啊!
杭电2001.为什么是wrong answer?
简单acm题,为什么会wrong answer?
Wrong Answer?
但是我写的就是wrong answer.