Submission #1917284
Source Code Expand
/*
AtCoder Regular Contest 004 A - 2点間距離の最大値 ( The longest distance )
Ver1
*/
/*
1-2,1-3...
2-3,2-4...
3-4,4-5...
各(*−*)2+(*−*)2を算出
最大値を確保
√最大値 を 求める
*/
int x[101];
int y[101];
#include<stdio.h>
#include<math.h>
//#define DEBUG1
//#define DEBUG2
int main() {
int n;
double l_max = 0;
scanf("%d", &n);
/*入力
*/
for (int i = 0; i < n; i++) {
scanf("%d", &x[i]);
scanf("%d", &y[i]);
}
#ifdef DEBUG1
printf("n = %d\n", n);
for (int i = 0; i < n; i++) {
printf("x[%d] = %d \t y[%d] = %d\n", i, x[i], i, y[i]);
}
#endif
/*最大値求める
*/
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if (l_max < pow(x[j] - x[i], 2) + pow(y[j] - y[i], 2)) {
l_max = pow(x[j] - x[i], 2) + pow(y[j] - y[i], 2);
#ifdef DEBUG1
printf("l_max = %f\n", l_max);
#endif
}
}
}
/*最大距離に変換する
*/
l_max = sqrt(l_max);
#ifdef DEBUG1
printf("l_max_ans = %f\n", l_max);
#endif
printf("%f\n", l_max);
#ifdef DEBUG2
getch();
#endif
return 0;
}
Submission Info
Compile Error
./Main.c: In function ‘main’:
./Main.c:32:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
./Main.c:36:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &x[i]);
^
./Main.c:37:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &y[i]);
^
Judge Result
Set Name |
All |
Score / Max Score |
100 / 100 |
Status |
|
Set Name |
Test Cases |
All |
00_max.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, 00_sample_05.txt, 01_rnd_00.txt, 01_rnd_01.txt, 01_rnd_02.txt, 01_rnd_03.txt, 01_rnd_04.txt, 01_rnd_05.txt, 01_rnd_06.txt, 01_rnd_07.txt, 01_rnd_08.txt, 01_rnd_09.txt, 01_rnd_10.txt, 01_rnd_11.txt, 01_rnd_12.txt, 01_rnd_13.txt, 01_rnd_14.txt, 01_rnd_15.txt, 01_rnd_16.txt, 01_rnd_17.txt, 01_rnd_18.txt, 01_rnd_19.txt |
Case Name |
Status |
Exec Time |
Memory |
00_max.txt |
AC |
1 ms |
128 KB |
00_sample_01.txt |
AC |
1 ms |
128 KB |
00_sample_02.txt |
AC |
1 ms |
128 KB |
00_sample_03.txt |
AC |
1 ms |
128 KB |
00_sample_04.txt |
AC |
1 ms |
128 KB |
00_sample_05.txt |
AC |
1 ms |
128 KB |
01_rnd_00.txt |
AC |
1 ms |
128 KB |
01_rnd_01.txt |
AC |
1 ms |
128 KB |
01_rnd_02.txt |
AC |
1 ms |
128 KB |
01_rnd_03.txt |
AC |
1 ms |
128 KB |
01_rnd_04.txt |
AC |
1 ms |
128 KB |
01_rnd_05.txt |
AC |
1 ms |
128 KB |
01_rnd_06.txt |
AC |
1 ms |
128 KB |
01_rnd_07.txt |
AC |
1 ms |
128 KB |
01_rnd_08.txt |
AC |
1 ms |
128 KB |
01_rnd_09.txt |
AC |
1 ms |
128 KB |
01_rnd_10.txt |
AC |
1 ms |
128 KB |
01_rnd_11.txt |
AC |
1 ms |
128 KB |
01_rnd_12.txt |
AC |
1 ms |
128 KB |
01_rnd_13.txt |
AC |
1 ms |
128 KB |
01_rnd_14.txt |
AC |
1 ms |
128 KB |
01_rnd_15.txt |
AC |
1 ms |
128 KB |
01_rnd_16.txt |
AC |
1 ms |
128 KB |
01_rnd_17.txt |
AC |
1 ms |
128 KB |
01_rnd_18.txt |
AC |
1 ms |
128 KB |
01_rnd_19.txt |
AC |
1 ms |
128 KB |