http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0034
#define _USE_MATH_DEFINES #include <iostream> #include <vector> #include <list> #include <cmath> #include <algorithm> using namespace std; int main () { int input[10],v1,v2; while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&input[0],&input[1],&input[2],&input[3],&input[4],&input[5],&input[6],&input[7],&input[8],&input[9],&v1,&v2) != -1) { double v1_d = (double)v1; double v2_d = (double)v2; double array[11] = {0}; array[0] = 0; for (int i=1; i < 11; i++) { array[i] = array[i-1] + input[i-1]; } //計算 double MAX = array[10] * 60; double b = MAX / v2; double x = (b * ((v1_d * v2_d) / (v1_d + v2_d))) / 60; for (int i=0; i < 11; i++) { if (x <= array[i]) { cout << i << endl; break; }else if(x < array[i]) { cout << i-1 << endl; break; } } } return 0; }