迴圈

輸入n

依題目計算花費

輸出

 

#include <iostream>

 

 

using namespace std;

int main()
{
    unsigned long long int cost;
    int n, number;

    while(cin >> n)
    {
        cost = 0;
        for(int i = 1; i<=n; i++)
        {
            cin >> number;
            cost += number*i;
        }

        cout << cost << endl;
    }

    return 0;
}
 

 
arrow
arrow
    全站熱搜

    大神(偽) 發表在 痞客邦 留言(0) 人氣()