A. Numbers

Unsolved.

 

B. Broken Watch

Solved.

题意:

一个圆盘上,有等分的n块区域,有三根指针,当三根指针分别位于两块区域的交界处时

指针的三点相连会形成一个三角形,求有多少个三角包含三指针的起点(即交汇处)

思路:

 1 #include<bits/stdc++.h>
 2 
 3 using namespace std;
 4 
 5 typedef unsigned long long ull;
 6 typedef long long ll;
 7 
 8 ll A, B, C, n;
 9 
10 int main()
11 {
12     while(~scanf("%lld %lld %lld %lld" ,&A, &B, &C, &n))
13     {
14         ull tmp = (n + 1) / 2;
15         tmp -= 2;
16         ull a = n, b = n - 1, c = n - 2;
17         if(a % 2 == 0) a /= 2;
18         else if(b % 2 == 0) b /= 2;
19         else if(c % 2 == 0) c /= 2;
20 
21         if(a % 3 == 0) a /= 3;
22         else if(b % 3 == 0) b /= 3;
23         else if(c % 3 == 0) c /= 3;
24         
25         ull ans = a * b * c;
26 
27         ans -= n * (tmp * (tmp + 1) / 2);
28 
29         if(A != B && B != C && C != A) ans = ans * 6;
30         else if(A != B || B != C || C != A) ans = ans * 3;
31 
32         printf("%llu\n", ans);
33     }
34     return 0;
35 }
View Code

相关文章: