题目:https://codeforces.com/problemset/problem/1113/A
分析:直接用贪心,因为油不够了肯定在前边加满最划算。
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int main()
{
int n,v;
while(cin >> n >> v)
{
int ans = 0;
int now = 0;
if(v > n - 1)
v = n - 1;
for(int i = 1;i < n;i ++)
{
if(now < n - i)
{
ans += (v - now) * i;
now = v;
}
now --;
}
cout << ans << endl;
}
return 0;
}