Problem ID :c023. 4.最遙遠的距離

New Thread

User 資測只過前三個

ww887766 SendIMessage
DuckEgg

c023. 4.最遙遠的距離 | From: 61.224.12.252 | Post Date:2016-01-28 11:27:29.0

#include<iostream>
#include<cmath>
using namespace std; 
int main()
{
int n,k=0;
int x[30000], y[30000];
double p[100];
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> x[i] >> y[i];
}
for (int i = 1; i <= n; i++)
{
double a, b;
a = x[i]*x[i];
b = y[i]*y[i];
p[i] = pow(sqrt(a+b),2);
}
double max = p[0];
for (int i = 1; i <= n; i++)
{

if (p[i] > max)
{
max = p[i];
k = i;
}
}
cout << k << " " << max << "\n";
system("pause");
}
哪裡錯啊大哭 
 


文章類型: 一般 | Reply | Back
User Re:資測只過前三個

hs410131 SendIMessage
不是啦那太誇張了 你怎麼不會扣血啊

c023. 4.最遙遠的距離 | From: 140.123.101.42 | Post Date:2016-01-29 18:06:05.0

//(system("pause")不是在<cstdlib>裡面嗎?可以用喔~)

#include<iostream>

#include<cmath>
using namespace std; 
int main()
{
int n,k=0;
int x[30000], y[30000];
double p[100];
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> x[i] >> y[i];
}
for (int i = 1; i <= n; i++)
{
double a, b;
                //這邊一定是整數,亦可用 int a,b; 
a = x[i]*x[i];
b = y[i]*y[i];
p[i] = pow(sqrt(a+b),2); //他是問平方和比大小,改成p[i]=a+b即可。
}
double max = p[0];
for (int i = 1; i <= n; i++)
{

if (p[i] > max)
{
max = p[i];
k = i;
}
}
cout << k << " " << max << "\n";
system("pause");
}
 


文章類型: 一般 | Reply | Back
User Re:資測只過前三個

hs410131 SendIMessage
不是啦那太誇張了 你怎麼不會扣血啊

c023. 4.最遙遠的距離 | From: 114.42.74.136 | Post Date:2016-01-29 18:11:40.0

#include<iostream>
#include<cmath>
using namespace std; 
int main()
{
int n,k=0;
int x[30000], y[30000];
double p[100];
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> x[i] >> y[i];
}
for (int i = 1; i <= n; i++)
{
double a, b;
a = x[i]*x[i];
b = y[i]*y[i];
p[i] = pow(sqrt(a+b),2);
}
double max = p[0];
for (int i = 1; i <= n; i++)
{

if (p[i] > max)
{
max = p[i];
k = i;
}
}
cout << k << " " << max << "\n";
system("pause");
//抱歉我搞錯重點了,你會NA的原因是因為資料型態的問題,如果用double會顯示科學記號,所以會錯
//全部改成int即可。 
 


文章類型: 一般 | Reply | Back
User Re:資測只過前三個

ww887766 SendIMessage
DuckEgg

c023. 4.最遙遠的距離 | From: 36.233.246.81 | Post Date:2016-01-30 10:52:51.0

謝謝
不過為何這兩題的數值又會差一呢 
NA
 第 4 點 (10%):WA
與正確輸出不相符(line:1)
您的答案為: 1 106851529
正確答案為: 1 106851530。 
 第 9 點 (10%):WA
與正確輸出不相符(line:1)
您的答案為: 78 165667876
正確答案為: 78 165667877 

 


文章類型: 一般 | Reply | Back
User Re:資測只過前三個

rscpp SendIMessage
二信阿C

c023. 4.最遙遠的距離 | From: 203.77.46.80 | Post Date:2016-02-12 00:19:49.0


題目要求 印出第幾個點 及 距離平方

所以過程中不需再算 sqrt了, 以免誤差

 


文章類型: 一般 | Reply | Back

New Thread

ZeroJudge Forum