fork download
  1. #include <bits/stdc++.h>
  2. #define endl "\n"
  3. using namespace std;
  4. int main()
  5. {
  6. ios_base::sync_with_stdio(0);
  7. cin.tie(0);
  8. int n, m;
  9. while (1)
  10. {
  11. cin >> m >> n;
  12. if (n == 0 && m == 0)
  13. return 0;
  14. double a[m + 1], ma = 0, k;
  15. for (int i = 1; i <= m; i++)
  16. {
  17. cin >> a[i];
  18. if (abs(a[i]) > ma)
  19. ma = abs(a[i]);
  20. }
  21. double s = ma;
  22. for (int i = 2; i <= n; i++)
  23. {
  24. ma = 0;
  25. for (int j = 1; j <= m; j++)
  26. {
  27. cin >> k;
  28. if (s != 0)
  29. a[j] *= k / s;
  30. if (abs(a[j]) > ma)
  31. ma = abs(a[j]);
  32. }
  33. s = ma;
  34. }
  35. int pos = 1;
  36. for (int i = 2; i <= m; i++)
  37. {
  38. if (a[i] >= a[pos])
  39. pos = i;
  40. }
  41. cout << pos << endl;
  42. }
  43. }
  44. /* Do Xuan Huong
  45. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  46. @@@@@@@@@@@@@@@@@@@@@@##################@@@@@@@@@@@@@@@@@@@@@
  47. @@@@@@@@@@@@@@@@#############################@@@@@@@@@@@@@@@@
  48. @@@@@@@@@@@@&####################################@@@@@@@@@@@@
  49. @@@@@@@@@@##########################################@@@@@@@@@
  50. @@@@@@@@##############################################@@@@@@@
  51. @@@@@@#################################################@@@@@@
  52. @@@@@####################################################@@@@
  53. @@@%#####################@@@@@@@@@@@######################@@@
  54. @@@###################@@@@@@@@@@@@@@@@@####################@@
  55. @@##################@@@@@@ @@@@@@##################@@
  56. @@#################@@@@@ @@@@###################@
  57. @@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@
  58. @ &@@@@ @@@@ .......@@
  59. @@ @@@@@@ @@@@@@ .......@@
  60. @@ @@@@@@@@@@@@@@@@@ .......@@@
  61. @@@ @@@@@@@@@@@ ......@@@@
  62. @@@@ ......@@@@@
  63. @@@@@@ ......@@@@@@
  64. @@@@@@@ .....@@@@@@@@
  65. @@@@@@@@@ .....@@@@@@@@@@
  66. @@@@@@@@@@@@ ....@@@@@@@@@@@@@
  67. @@@@@@@@@@@@@@@@ ....@@@@@@@@@@@@@@@@
  68. @@@@@@@@@@@@@@@@@@@@@% .@@@@@@@@@@@@@@@@@@@@@@
  69. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  70. */
Success #stdin #stdout 0.01s 5304KB
stdin
3 3

20 10 30

15 20 20

30 30 20

3 2
2 -2 2
2 -2 2
0 0
stdout
3
3