Advertisement
jeff69

Untitled

Mar 18th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1.  
  2. #include <iomanip>
  3. #include <iostream>
  4. #include <functional>
  5. #include <algorithm>
  6. #include <math.h>
  7. #include <cmath>
  8. #include <string>
  9. #include <vector>
  10. #include<set>
  11. #include<map>
  12. #include <time.h>
  13. typedef long long ll;
  14.  
  15. using namespace std;
  16. int solve(int a){
  17. return a*a - ((a + 1)*a) / 2;
  18. }
  19. int factor(int x){
  20. if (x == 0)return 1;
  21. else return x*factor(x - 1);
  22. }
  23. int main(){
  24. int a, b;
  25. cin >> a >> b;
  26. b = min(a / 2, b);
  27. int ans = 0;
  28. ans += solve(2 * b);
  29. ans += 2*b*(a - 2 * b);
  30. cout << ans;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement