summaryrefslogtreecommitdiff
path: root/euler99.c
blob: e33779698caa97a9dfc65313b25f2ef1ac842968 (plain)
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
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>

struct elem
{
	int idx;
	double v;
};

int comp(const void *s, const void *t)
{
	struct elem *ss = (struct elem*)s;
	struct elem *tt = (struct elem*)t;
	if (ss->v < tt->v)
		return -1;
	if (ss->v > tt->v)
		return 1;
	return 0;
}

int main()
{
	struct elem arr[100000];
	int n;
	char buffer[1000];

	n = 0;
	while (fgets(buffer, 1000, stdin)) {
		if (strlen(buffer) < 3)
			break;
		int a = atoi(buffer);
		int b = atoi(strchr(buffer, ',')+1);
		arr[n].idx = n + 1;
		arr[n].v = b * log(a);
		n ++;
	}
	qsort(arr, n, sizeof(arr[0]), comp);
	printf("%d\n", arr[n-1].idx);
}