P28227 [洛谷] [SEERC2018] Broken Watch
入门
题目描述

Problem Description

A UFO has crashed on Earth. The alien captain survived, but his watch did not.

The alien watch is very similar to a human watch: it has a dial with a diameter of 30 mm and three hands with lengths \( A, B, \) and \( C \) \( (1000 \leq A, B, C \leq 15000) \) micrometers. However, the aliens use different time units: there are \( N \) \( (2 \leq N < 2^{32}) \) seconds in a minute. Therefore, the dial has \( N \) marks instead of 60.

The glass panel of the watch is shattered, and the hands are loose: they can rotate freely independently. By pointing the three hands at any marks, a triangle can be formed with the tips of the hands (provided the hands are not collinear).

While waiting for rescue, the alien captain pondered a question: among the triangles formed in this manner, how many contain the center of the dial (denoted as \( M \))? (Triangles where the center lies on one of the sides should also be counted.)

Input Format

A single line containing the integers \( A, B, C, \) and \( N \), separated by a single space.

Output Format

Output the value of \( M \mod 2^{64} \).

Sample Input and Output

Sample Input #1

15000 15000 15000 2

Sample Output #1

0

Sample Input #2

5000 10000 15000 3

Sample Output #2

6

Sample Input #3

15000 15000 15000 3

Sample Output #3

1

Sample Input #4

15000 15000 15000 4

Sample Output #4

4

Sample Input #5

15000 15000 15000 5

Sample Output #5

5

Sample Input #6

15000 15000 15000 6

Sample Output #6

14
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
15000 15000 15000 2
样例输出
0