Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define fastread()(ios_base::sync_with_stdio(false),cin.tie(NULL));
- int main()
- {
- int n,v;
- scanf("%d %d",&n,&v);
- if(v>=n)printf("%d\n",n-1);
- else if(v-1==n)
- {
- printf("%d\n",v);
- }
- else
- {
- int i,res=0, pos;
- for(i=1;i<=n-v;i++)
- {
- if(i==1)res=i*v;
- else
- {
- res+=i;
- }
- }
- printf("%d\n",res);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement