只看了前面三题,都很水。但是做的很不好。

A.Sockets    题目确实挺晦涩的,但是勉强看着Sample就一下懂了,按照给的supply-line filter排个序,然后由大到小累积,看需要几个能满足所有Devices,如果不行就 -1

View Code

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <list>
#include <deque>
#include <queue>
#include <functional>
#include <bitset>
#include <set>
using namespace std;int e[55];int main()
{int n,m,k,i;cin >> n >> m >> k;for(i = 0; i < n; i++)cin >> e[i];sort(e, e+n);int ok = 0;int ans = 0;int cur = k;if(cur >= m)    ok = 1;for(i = n-1; i >= 0 && !ok; i--){cur = cur-1 + e[i];ans++;if(cur >= m){ok = 1;break;}}   if(ok)  cout << ans << endl;else    cout << "-1" << endl;return 0;
}

B.Playing Cubes  Petya第一个方块放的颜色决定方块的排列。可以模拟放方块的过程来得到结果。答案为 max(red, blue)-1, min(red, blue)

C.View Angle   

从原点(0,0)出发的的n条射线,求最小角度包含所有射线。

可以用atan2()函数。

对于任意不同时等于0的实参数x和y,atan2(y,x)所表达的意思是坐标原点为起点,指向(x,y)的射线在坐标平面上与x轴正方向之间的角的角度度。当y>0时,射线与x轴正方向的所得的角的角度指的是x轴正方向绕逆时针方向到达射线旋转的角的角度;而当y<0时,射线与x轴正方向所得的角的角度指的是x轴正方向绕顺时针方向达到射线旋转的角的角度。

当弧度值小于0时候,加上2*M_PI,修正成从0开始。

将这些射线按照弧度值升序,然后依次枚举相邻两个射线的角度,别忘了处理首尾两个射线,最后用360.0 - 枚举出最大的相邻射线弧度,乘以180.0/M_PI,就是答案。

View Code

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <vector>
#include <map>
#include <list>
#include <deque>
#include <queue>
#include <functional>
#include <bitset>
#include <set>
using namespace std;vector<double> e;int main()
{int n,i;double x,y;cin >> n;for(i = 0; i < n; i++){scanf("%lf %lf", &x,&y);double tmp = atan2(y,x);if(tmp < 0)e.push_back(2*M_PI+tmp);elsee.push_back(tmp);}sort(e.begin(), e.end());double dif = 0.0;for(i = 1; i < e.size(); i++)dif = max(dif, e[i]-e[i-1]);dif = max(dif, 2*M_PI - (e[n-1]-e[0]));printf("%.10lf\n", 360.0 - dif*180.0/M_PI);return 0;
}

D.Sum

自己YY了,结果过了。因为满足ai ≤ ai+1 ≤ 2ai-1 ,所以有个想法,设定一个变量mend = 0作为修正变量,从尾到头不断根据mend变量来调整取正还是取负。

但是遇到3 3 5这种,从尾到头mend最后为-1,那么就把正负号颠倒过来好了。看到Tag有DP,不知道该怎么想,求各位大牛指导。

View Code

#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <numeric>
#include <functional>
#include <iterator>
#include <typeinfo>
#include <utility>
#include <memory>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstddef>
#include <complex>
#include <ctime>
#include <cassert>
using namespace std;
static inline bool get(int &v)
{int s = 1, c;while(!isdigit(c = getchar())&&c != '-'){if(c == EOF)break ;}if(c == EOF) return 0;if(c == '-') s = 0 , v = 0;else v = c^48;for(;isdigit(c = getchar());v = (v << 1) + (v << 3) + (c ^ 48));v = (s ? v : -v);return 1 ;
}vector<int> e;
char ans[100005];
int main()
{int n,i,tmp;get(n);for(i = 0;i < n; i++){get(tmp); e.push_back(tmp);}int mend = 0;for(i = n-1; i >= 0; i--){if(mend > 0)    {mend -= e[i];ans[i] = '-';}else    {mend += e[i];ans[i] = '+';}}if(mend < 0){for(i = 0; i < n; i++){if(ans[i] == '+')    printf("-");else    printf("+");}}else{for(i = 0; i < n; i++){printf("%c", ans[i]);}}printf("\n");return 0;
}

E.Greedy Elevator

转载于:https://www.cnblogs.com/tiny656/archive/2013/01/09/2852458.html

Codeforces Round #159 (Div. 2)相关推荐

  1. Codeforces Round #506 (Div. 3)

    Codeforces Round #506 (Div. 3) 实习期间事不多,对div3 面向题解和数据编程了一波 A. Many Equal Substrings 题目链接 A题就是找后缀和前缀重合 ...

  2. Codeforces Round #563 (Div. 2)/CF1174

    Codeforces Round #563 (Div. 2)/CF1174 CF1174A Ehab Fails to Be Thanos 其实就是要\(\sum\limits_{i=1}^n a_i ...

  3. 构造 Codeforces Round #302 (Div. 2) B Sea and Islands

    题目传送门 1 /* 2 题意:在n^n的海洋里是否有k块陆地 3 构造算法:按奇偶性来判断,k小于等于所有点数的一半,交叉输出L/S 4 输出完k个L后,之后全部输出S:) 5 5 10 的例子可以 ...

  4. Codeforces Round #696 (Div. 2) (A ~ E)超高质量题解(每日训练 Day.16 )

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Codeforces Round #696 (Div. 2) (A ~ E)超高质量题解 比赛链接:h ...

  5. Codeforces Round #712 Div.2(A ~ F) 超高质量题解(每日训练 Day.15 )

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Codeforces Round #712 Div.2(A ~ F) 题解 比赛链接:https:// ...

  6. Codeforces Round #701 (Div. 2) A ~ F ,6题全,超高质量良心题解【每日亿题】2021/2/13

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 目录 A - Add and Divide B - Replace and Keep Sorted C ...

  7. Codeforces Round #700 (Div. 2) D2 Painting the Array II(最通俗易懂的贪心策略讲解)看不懂来打我 ~

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 整场比赛的A ~ E 6题全,全部题目超高质量题解链接: Codeforces Round #700 ...

  8. Codeforces Round #699 (Div. 2) F - AB Tree(贪心、树上DP)超级清晰,良心题解,看不懂来打我 ~

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Codeforces Round #699 (Div. 2) F - AB Tree Problem ...

  9. Codeforces Round #699 (Div. 2) (A ~ F)6题全,超高质量良心题解【每日亿题】2021/2/6

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Codeforces Round #699 (Div. 2) (A.B.C)[每日亿题]2021/2/ ...

  10. Codeforces Round #698 (Div. 2)(A ~ F)6题全,超高质量题解)【每日亿题】2021/2/4

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 目录 [每日亿题]Codeforces Round #698 (Div. 2)(A ~ F)6题全,超 ...

最新文章

  1. 服务器 声音文件 nginx,docker nginx搭建视频音频服务器
  2. eclipse android环境配置
  3. [LeetCode] Interleaving String
  4. P3750-[六省联考2017]分手是祝愿【期望dp】
  5. 【转】前端的BFC、IFC、GFC和FFC
  6. php70w mysql.x8664_LAMP环境的搭建(三)----PHP7的安装
  7. 18 File Duplication and Pipes
  8. Python 入门,看这篇就够了
  9. Ubuntu之systemd延时启动服务
  10. mysql where执行顺序_mysql where执行顺序
  11. ESP32 之 ESP-IDF 教学(十一)WiFi篇—— WiFi两种模式
  12. Python培训包食宿
  13. 使用libyuv对YUV数据进行缩放,旋转,镜像,裁剪等操作
  14. 聊天类APP的测试点
  15. oracle混音插件教程,【图片】【教学】waves混音插件官方教学贴,长期更新_混音吧_百度贴吧...
  16. stylecloud 自定义蒙版
  17. html引入png不显示透明北京,完美解决透明png图片及透明png背景,兼容所有浏览器...
  18. 2017年高教社杯全国大学生数学建模竞赛(A题)
  19. Microsoft Compatibility Telemetry占用系统cpu
  20. 小程序通过摄像头拍摄个人身份证

热门文章

  1. Mr.Panda and TubeMaster Gym - 101194J (二分染色有源汇上下界最大费用流)
  2. mpvue 中使用 iconfont
  3. 常见的Java基础的面试题
  4. Python技术公众号100天了
  5. Percona Toolkit工具箱的安装与使用--完成复杂的mysql操作。
  6. vc6.0安装过程中出现的问题——解决
  7. 分享非常宝贵的工作经
  8. SCOM 2012 RC 升级到 SCOM 2012 RTM 手记
  9. 三块金砖---感晤CIO的人生‏
  10. 许多自己正在总结的东东