Codeforces Round #579 (Div. 3)

题目链接:http://codeforces.com/contest/1203

A. Circle of Students

题意:n个数列 看看是不是1 - n或者 n - 1顺序(头尾相连)。

思路:检查相邻俩个元素差值等不等于一 并且不等于 n - 1,后面补判断条件绝对值忘写了wa了,透!

AC代码:

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int a[205];
 4 int main()
 5 {
 6     int t;
 7     cin >> t;
 8     while(t--)
 9     {
10         int n;
11         cin >> n;
12         bool flag = true;
13         for(int i = 0;i < n;i++)
14         {
15             cin >> a[i];
16             if(i && abs(a[i] - a[i-1]) > 1 && abs(a[i] - a[i-1]) != n - 1) flag = false;
17         }
18         if(flag) cout << "YES" << endl;
19         else cout << "NO" << endl;
20     }
21     return 0;
22 }

B. Equal Rectangles

题意: 4n个边 问你能不能组成大小相同的n个方形。

思路:面积肯定最大最小的相乘 最后检查一下每个元素是不是出现俩次并且能凑出面积即可。 本来一下子想到了,为什么会觉得面积不是大小相乘呢,为什么就不信第一直觉呢。

AC代码:

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 const int maxn = 1e5 + 5;
 4 int a[maxn];
 5 int main(){
 6     int t;
 7     cin >> t;
 8     while(t --){
 9         int n;
10         cin >> n;
11         n = 4 * n;
12         for(int i = 0; i < n; i++)
13             cin >> a[i];
14         sort(a,a+n);
15         int area = a[0] * a[n-1];
16         int l = 0,r = n -1;
17         while(l < r){
18             if( l + 1 < r - 1 && a[l] == a[l+1] && a[r] == a[r-1] && a[l] * a[r] == area)
19             {
20                 l += 2,r -= 2;
21                 continue;
22             }
23             else {
24                 break;
25             }
26         }
27         if(l == r + 1) cout << "YES" << endl;
28         else cout << "NO" << endl;
29     }
30 }

C. Common Divisors

题意:求数组所以元素的都有的因子有几个。

思路:一眼就是把所有数的gcd求出来,然后gcd的因子数就是答案,结果写一半把 gcd 当成最小公倍数然后在那里发呆,我他么是傻子吧我在做什么啊。

AC代码:

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int main()
 4 {
 5     int n;
 6     long long x;
 7     cin >> n;
 8     long long d = 0;
 9     for(int i = 0;i < n;i++){
10          cin >> x;
11         d =__gcd(d,x);
12     }
13     int ans = 0;
14     for(long long i = 1;i <= sqrt(d);i++){
15         if(d % i == 0){
16             if ( i * i == d)
17                     ans += 1;
18                 else
19                     ans += 2;
20         }
21     }
22     cout << ans << endl;
23 }

E. Boxers

题意: n 个人,每个人体能可以 增加减少1,问最多有多少人体能不同。

思路:贪心,每次标记都优先给体能 - 1,如果体能- 1的值有人了 ,就给自己,自己的值也有了 就给+1的, 这题看完想到了这个 结果 当时看到罗老板WA了,就觉得没这么简单,而且BC都没做,想想还是做 BC去,结果罗老板第二天告诉我这题就是这样,心态炸了都 ,真难受。。

AC代码

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 const int maxn = 2e5 + 5;
 4 int a[maxn];
 5 int vis[maxn];
 6 int main()
 7 {
 8     int n;
 9     cin >> n;
10     for(int i = 0;i < n;i++)
11     {
12         cin >> a[i];
13     }
14     sort(a,a + n );
15     for(int i = 0;i < n;i++)
16     {
17         if(vis[a[i] - 1] == 0 && a[i] != 1)
18             vis[a[i] - 1 ] = 1;
19         else if( vis[a[i]] == 0)
20             vis[a[i]] = 1;
21         else vis[a[i] + 1] = 1;
22     }
23     int ans = 0;
24     for(int i = 0;i < maxn;i++)
25     {
26         if(vis[i]) ans++;
27     }
28     cout << ans << endl;
29     return 0;
30 }

总结:打了这么久,打DIV3还是只能签A,觉得自己真的菜的不行,想不通为什么比赛的时候就脑子不好使,感觉平时不这样,郁闷了一整天,还影响了第二天比赛队内的气氛,真不好受。

相关文章

Css常用的排序方式权重分配 排序方式: 1、按类型&#160;...
原文:https://www.cnblogs.com/wenruo/p/9732704.html 先上...
css属性:word-wrap:break-word; 与 word-break:break-all 的...
https://destiny001.gitee.io/color/
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML...
css之background的cover和contain的缩放背景图 对于这两个属...