博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #227 (Div. 2) 解题报告
阅读量:7281 次
发布时间:2019-06-30

本文共 3250 字,大约阅读时间需要 10 分钟。

Problem A 

题意:给出两个时间计算上面减下面。水题

代码如下:

1 //2014-01-30-21.18 2 #include 
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 #include
13 #define MP(a, b) make_pair(a, b)14 #define PB(a) push_back(a)15 16 using namespace std;17 18 typedef long long ll;19 typedef pair
pii;20 typedef pair
puu;21 typedef pair
pid;22 typedef pair
pli;23 typedef pair
pil;24 25 const int INF = 0x3f3f3f3f;26 const double eps = 1e-6;27 28 int main()29 {30 // freopen("in.txt", "r", stdin);31 32 int a, b, c, d;33 while(scanf("%d:%d", &a, &b)!=EOF){34 scanf("%d:%d", &c, &d);35 int f = b>=d?0:1;36 b = (b-d+60)%60;37 a = (a+24-f-c)%24;38 printf("%02d:%02d\n", a, b);39 // cout << a << ' ' << b << endl;40 }41 return 0;42 }
View Code

Problem B 

题意:George要准备一场比赛现在一有m个问题第i个难度为a[i],比赛至少有n个问题每个问题难度必须是b[i].george可以把一个难度大的问题降低。问你他最少需要新出几道题才能满足需要。

思路:由于大的能变小的,所以贪心一下用a中最小的尝试匹配b中最小的。即可得出答案

代码如下:

1 //2014-01-30-21.18 2 #include 
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 #include
13 #define MP(a, b) make_pair(a, b)14 #define PB(a) push_back(a)15 16 using namespace std;17 18 typedef long long ll;19 typedef pair
pii;20 typedef pair
puu;21 typedef pair
pid;22 typedef pair
pli;23 typedef pair
pil;24 25 const int INF = 0x3f3f3f3f;26 const double eps = 1e-6;27 const int LEN = 10010;28 29 int main()30 {31 // freopen("in.txt", "r", stdin);32 33 int n, m, a[LEN], b[LEN];34 while(scanf("%d%d", &n, &m)!=EOF){35 for(int i=0; i
=a[top]){top++;if(top==n)break;}42 }43 printf("%d\n", n-top);44 }45 return 0;46 }
View Code

Problem C 

题意:有一个数列b能执行一系列操作:

每次选i,j满足b[i]>b[j]。

v = concat(bi, bj),就是把大的数拼接在小的前面。

将v加入末尾。

删除b[i],b[j]

最终得到一个数。现在告诉你这个数,问你原先数列最多可能有几个数。

思路:仔细观察操作我们可以知道,只要满足每次把大数截断并且满足前面大于后面我们就能多造出来一个数并且对前面的那个数递归的解决问题。最终得到答案

代码如下:

1 //2014-01-30-21.18 2 #include 
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 #include
13 #define MP(a, b) make_pair(a, b)14 #define PB(a) push_back(a)15 16 using namespace std;17 18 typedef long long ll;19 typedef pair
pii;20 typedef pair
puu;21 typedef pair
pid;22 typedef pair
pli;23 typedef pair
pil;24 25 const int INF = 0x3f3f3f3f;26 const double eps = 1e-6;27 const int LEN = 1000000+10;28 char str[LEN], a[LEN], b[LEN];29 30 //b是不是比a大31 bool isbig(int i, int l){32 int la = i, lb = l-i;33 if(la>lb) return true;34 else if(la
str[i+pos]) return true;38 if(str[pos] < str[i+pos]) return false;39 }40 return true;41 }42 }43 44 int main()45 {46 // freopen("in.txt", "r", stdin);47 48 while(scanf("%s", str)!=EOF){49 int i = strlen(str)-1, l = i+1, ans = 0;50 while(i>=0){51 if(str[i] != '0') {52 if(isbig(i, l)){53 ans++;54 l = i;55 }56 }57 i--;58 }59 printf("%d\n", ans+1);60 }61 return 0;62 }
View Code

 

转载于:https://www.cnblogs.com/shu-xiaohao/p/3536702.html

你可能感兴趣的文章
协程(Coroutine)并不是真正的多线程(转)
查看>>
java 中 ResourceBundle 使用 国际化使用
查看>>
使用Git Bash for Windows
查看>>
【087】Stylish & Greasemonkey
查看>>
uva 10626 - Buying Coke(记忆化搜索)
查看>>
WIN8.1 PRO RTM VOL.Enterprise.2013.10.17
查看>>
arcengine 要素渲染和专题图制作
查看>>
安装VS2005的sp1补丁错误,未通过数字签名检查(轉)
查看>>
XP里查看进程详细信息的命令
查看>>
PHP函数详细剖析之rtrim函数 By ACReaper
查看>>
如何禁止页面滚动
查看>>
Docker 安装
查看>>
Struts1 MVC框架的工作原理
查看>>
xdebug调试一直等待连接
查看>>
写个线程池
查看>>
android面试题之四
查看>>
NET 开发者必备的工具箱
查看>>
程序员爬《邪不压正》影评,发现细丝极恐的细节,电影就要这样看
查看>>
这大概是全世界最酷的“工牌”!拿到的中国人个个都不简单
查看>>
当京东小哥坐在电影院的前排,抬头看到了这样的一幕
查看>>