Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication172.cpp : Defines the entry point for the console application.
- //
- #include <iomanip>
- #include <iostream>
- #include <functional>
- #include <algorithm>
- #include <math.h>
- #include <cmath>
- #include <string>
- #include <vector>
- #include<set>
- #include<map>
- #include <time.h>
- typedef long long ll;
- using namespace std;
- int solve(int a){
- return a*a - ((a + 1)*a) / 2;
- }
- int factor(int x){
- if (x == 0)return 1;
- else return x*factor(x - 1);
- }
- int main(){
- int a, b;
- cin >> a >> b;
- if (a / 2 == 0){ cout << 0; return 0; }
- int z = b % (a / 2);
- int cmo = (b - a / 2) % (2);
- b = min(a / 2, b);
- int ans = 0;
- if (cmo > 0 && z == 0)b--;
- ans += solve(2 * b);
- ans += 2 * b*(a - 2 * b);
- cout << ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement