Advertisement
jakaria_hossain

codeforce - Sasha and His Trip

Mar 6th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define fastread()(ios_base::sync_with_stdio(false),cin.tie(NULL));
  4. int main()
  5. {
  6. int n,v;
  7. scanf("%d %d",&n,&v);
  8. if(v>=n)printf("%d\n",n-1);
  9. else if(v-1==n)
  10. {
  11. printf("%d\n",v);
  12. }
  13. else
  14. {
  15. int i,res=0, pos;
  16. for(i=1;i<=n-v;i++)
  17. {
  18. if(i==1)res=i*v;
  19. else
  20. {
  21. res+=i;
  22. }
  23. }
  24. printf("%d\n",res);
  25. }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement