Problem A Collecting Beats is Fun

题意:就是音乐游戏在4*4的网上一些格子需要在固定的时间点,告诉你一只手同一时间能点几个。问你能不能通关(就是一个不丢)

思路:水题 。我开了一个数组统计一下每个时间出现的格子数。最后扫一遍判断有没有不能点完的就OK了

代码如下:

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4 #include <cstdlib>
 5 #include <algorithm>
 6 #include <utility>
 7 #include <queue>
 8 #include <vector>
 9 #include <stack>
10 #define INF 0x7fffffff
11 #define ll long long
12 #define eps 1E-6
13
14 using namespace std;
15
16 int main()
17 {
18 //    freopen("in.txt", "r", stdin);
19     int n, cnt[11];
20     while(scanf("%d", &n)!=EOF){
21         memset(cnt, 0, sizeof cnt);
22         for(int i=0; i<4; i++){
23             for(int j=0; j<4; j++){
24                 char temp;
25                 cin >> temp;
26                 if(temp!='.') cnt[temp-'0']++;
27             }
28         }
29         int ans = 1;
30         for(int i=0; i<10; i++){
31             if(cnt[i]>2*n)ans = 0;
32         }
33         if(ans) cout << "YES" << endl;
34         else cout << "NO" << endl;
35     }
36     return 0;
37 }

View Code

Problem B Making Sequences is Fun

题意:给你一个m你要找(m,m+1,。。。)这个数列。每往这个数列中加入一个数花费是S(x)*k,S(x)表示数字的位数,问你最长能加多少个数?

思路:我用的方法很暴力,首先看m为几位数假设为a位,那么看看把a位中比m大的全部加进来,若不行那直接算出来多少个数。若可以加则从a+1开始枚举,直到剩下来的费用已经不能把b位的数全加进来了。这是在算一下b位的书能加几个就OK了。

代码如下:

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4 #include <cstdlib>
 5 #include <cmath>
 6 #include <algorithm>
 7 #include <utility>
 8 #include <queue>
 9 #include <vector>
10 #include <stack>
11 #define INF 0x7fffffff
12 #define ll long long
13 #define eps 1E-6
14
15 using namespace std;
16
17 ll w, m ,k, ans, cost[30];
18
19 ll Pow(ll a, ll b){
20     ll ret = 1;
21     while(b--){
22         ret*=a;
23     }
24     return ret;
25 }
26
27 int main()
28 {
29 //    freopen("in.txt", "r", stdin);
30
31     memset(cost, 0, sizeof cost);
32     for(ll i=1; i<21; i++){
33         cost[i] = Pow(10, i);
34         for(int j=1; j<i; j++){
35             cost[i]-=cost[j];
36         }
37     }
38     while(cin >> w >> m >> k){
39         ll mon = w/k;
40         ll ii;
41         for(ii=1; ii<20; ii++){
42             if(Pow(10, ii)>m)break;
43         }
44         ll cc = (Pow(10, ii)-m)*ii, ans = 0;
45         if(mon<=cc) ans = mon/ii;
46         else{
47             mon-=cc;
48             ans+=Pow(10, ii)-m;
49             while(mon>0){
50                 ++ii;
51                 if(cost[ii]*ii<=mon){
52                     mon-=cost[ii]*ii;
53                     ans+=cost[ii];
54                 }else break;
55             }
56             ans+=mon/ii;
57         }
58         cout << ans << endl;
59     }
60     return 0;
61 }

View Code

Problem C Counting Kangaroos is Fun

题意:一个袋鼠可以装下另一个袋鼠当且仅当他的体重是另外一个的两倍。在袋鼠口袋里有东西的时候就不能再装别的东西或者被别的袋鼠装了,一个袋鼠被装了以后就看不见了。问你最少会看见多少只袋鼠?

思路:二分答案。每一次判断答案是否可行就是看前mid个是否能被后mid个装下(排序好的)。前两天在刷uva今天补上这一题。

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4 #include <algorithm>
 5 #include <queue>
 6 #include <vector>
 7 #include <stack>
 8 #define LEN 1000100
 9 #define INF 0x7fffffff
10 #define eps 1e-6
11 #define ll long long
12
13 using namespace std;
14
15 int a[LEN], n;
16
17 void debug()
18 {
19     for(int i=0; i<n; i++){
20         cout << a[i] << ' ';
21     }cout << endl;
22 }
23
24 bool check(int pos){
25     for(int i=0; i<pos; i++){
26         if((2*a[i])>a[n-pos+i])return false;
27     }
28     return true;
29 }
30
31 int main()
32 {
33     freopen("in.txt", "r", stdin);
34
35     while(scanf("%d" ,&n)!=EOF){
36         for(int i=0; i<n; i++){
37             scanf("%d", &a[i]);
38         }
39         sort(a, a+n);
40         int l = 0, r = n/2;
41         while(l<r){
42             int mid = (l+r+1)/2;
43             if(check(mid))l = mid;
44             else r = mid-1;
45         }
46         cout << n-l << endl;
47     }
48     return 0;
49 }

View Code

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

Codeforces Round #219 (Div. 2) 解题报告相关推荐

  1. CodeCraft-19 and Codeforces Round #537 (Div. 2)解题报告

    Codeforces Round #537 (Div. 2) 题解报告 A. Superhero Transformation 题意 问能否通过把辅音字母换成另一个辅音字母,元音字母换成另一个元音字母 ...

  2. Codeforces Round #702 (Div. 3)解题报告

    Codeforces Round #702 (Div. 3) 全部题解 读错题意,写了半天真是心态爆炸,总的来看这次题目不难的. A. Dense Array http://codeforces.co ...

  3. Codeforces Round #264 (Div. 2) 解题报告

    Source:  http://codeforces.com/contest/463 打得比较差..第三题想写nlgn的,结果调了很久又wa,以为写挫,过了很久发现做法有问题..最后两题惨淡收场.第四 ...

  4. Codeforces Round #535 (Div. 3) 解题报告

    CF1108A. Two distinct points 做法:模拟 如果两者左端点重合就第二条的左端点++就好,然后输出左端点 #include <bits/stdc++.h> usin ...

  5. Codeforces Round #578 (Div. 2) 题解报告

    A. Hotelier sb模拟,直接按题意模拟就可以了. B. Block Adventure Gildong is playing a video game called Block Advent ...

  6. BestCoder Round #77 (div.2)解题报告

    昨晚和Yveh合作的成果-- T1 传送门 题意:给一个正整数集合,求集合中各个子集里各元素的总异或 思路:对于一个数x对自己异或的结果,异或偶数次是x,奇数次为0,而且一个集合的非空子集数目为2n− ...

  7. Codeforces Round #700 (Div. 2)A~D2解题报告

    Codeforces Round #700 (Div. 2)A~D2解题报告 A Yet Another String Game 原题链接 http://codeforces.com/contest/ ...

  8. Codeforces Round #693 (Div. 3)A~G解题报告

    Codeforces Round #693 (Div. 3)A~G解题报告 A Cards for Friends 原题信息 http://codeforces.com/contest/1472/pr ...

  9. Codeforces Round #697 (Div. 3)A~G解题报告

    Codeforces Round #697 (Div. 3)A~G解题报告 题 A Odd Divisor 题目介绍 解题思路 乍一想本题,感觉有点迷迷糊糊,但是证难则反,直接考虑没有奇数因子的情况, ...

最新文章

  1. 浅析正则表达式模式匹配的 String 方法
  2. 携手320+合作伙伴,英伟达扔下一枚自动驾驶炸弹,打响新年越野赛 | CES2018
  3. 大型网站架构不得不考虑的10个问题,互联网营销
  4. 【安卓开发 】Android初级开发(二)Activity启动模式
  5. 【Go语言】面向对象扩展——接口
  6. 训练日志 2019.2.16
  7. mosquitto支持websocket的使用方法
  8. VMware ESXi/ESX 的内部版本号和版本 (2143832)-2020-10-27更新
  9. 清华大学信息 计算机科学与技术,清华大学信息科学与技术国家实验室
  10. Custom Sharepoint Lookup Field
  11. 3v stm32 供电 晶振起振_晶振起振_单片机晶振不起振原因及解决方法
  12. Kafka应用实践与生态集成
  13. C语言-数组练习题(附答案)
  14. Simulink之晶闸管(可控硅SCR)
  15. lstm 做航迹预测预测_用lstm预测酒店收入的第一步
  16. 认识CPU的工作原理
  17. 2019 大前端是什么,我们该学什么?
  18. QQ被盗的自救、事故分析
  19. 5G NGC — NRF 网络注册功能
  20. 关于软件工程第一个博客

热门文章

  1. php ==gt;,谈谈PHP中的 -gt;、=gt; 和 :: 符号 - 易采站长站
  2. php中高光显示的高数,[技术博客]React Native——HTML页面代码高亮数学公式解析...
  3. android百度地图定位自定义图标,百度地图SDK集成及根据坐标实现定位(android studio开发)...
  4. 树莓派 烧录arm64架构centos7
  5. vue 指令 v-on 函数传参
  6. vue 打开html流_解决Vue项目打包后打开index.html页面显示空白以及图片路径错误的问题...
  7. uint32是什么数据类型_C++编程基础: 4. 数据类型
  8. Docker 学习总结(71)—— Docker、Docker Compose、Docker Swarm 之间的区别
  9. Docker学习总结(34)——新手使用Docker的11条准则
  10. Java基础学习总结(92)——Java编码规范之排版、注释及命名