Advertisement
jeff69

Untitled

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