SRM 491 div 1

easy
和sとして、「和がsになる2つの数字の組合せ」を3つ取ってくる円順列を考えて、sがmax(7,K)から2N-5までの円順列の和を求めればよい。

#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

class FoxMakingDice{
public:
	long long c3(long long n){
		return n*(n-1)*(n-2)/6;
	}
	long long theCount(int N, int K){
		long long ans = 0;
		for(int s = max(7,K); s <= 2*N-5; s++){
			if(N+1>=s){
				ans += c3((s-1)/2) * 2;
			}else{
				ans += c3((2*N-s+1)/2) * 2;
			}
		}
		return ans;
	}
};