A.Accurate Movement(复现赛)

题意:两个木块最左边都在0的位置,最右边分别为a,b(b>a),并且短的木条只能在长木条内移动,问两个木条需要移动多少次才能使两个木条的右端都在n

思路:短木条最少移动(n-a)/(b-a),如果(n-a)%(b-a)不为0,那么还需要再多移动一次,才能到达最右边,长木条以此类推

代码:

 1 #include<iostream>
2 #include<algorithm>
3 #include<cmath>
4 #include<cstdio>
5 using namespace std;
6 int main(){
7 int a,b,n;
8 scanf("%d %d %d",&a,&b,&n);
9 int sum=0;
10 if((n-a)%(b-a)==0){
11 sum+=(n-a)/(b-a);
12 }else{
13 sum+=(n-a)/(b-a)+1;
14 }
15 if((n-b)%(b-a)==0){
16 sum+=(n-b)/(b-a);
17 }else{
18 sum+=(n-b)/(b-a)+1;
19 }
20 printf("%d\n",sum);
21 }

A. Park Lighting(#645)

题意:安放路灯在棱上,可以点亮以这条楞为公共线的正方形小块上,问需要多少个灯才能点亮整个大矩形,输入为大矩形的场合宽

思路:直接判断矩形个数是不是偶数,如果是,那么就可以用(长×宽)/2,如果不是,就是需要额外的一个点亮剩下的一个

代码:

 1 #include<iostream>
2 #include<algorithm>
3 #include<cstdio>
4 #include<cmath>
5 using namespace std;
6 int main(){
7 int t;
8 scanf("%d",&t);
9 while(t--){
10 int a,b;
11 scanf("%d %d",&a,&b);
12 if((a*b)%2==1){
13 printf("%d\n",a*b/2+1);
14 }else{
15 printf("%d\n",a*b/2);
16 }
17 }
18 }

B. Maria Breaks the Self-isolation

题意:起初院子中一个老奶奶,然后它可以喊任意个其他的老奶奶,但是这些老奶奶出现的要求是,当她出现时必须看到除她以外的a[i]个人,判断院子中最多可以喊多少个老奶奶

思路:采用优先队列,从需要看见人数最多的老奶奶开始,如果这个数小于1加上院子中可进去的人数(先假设同时间去),那么就说明可以同时来,如果大于,也就是说即使同一时间进去也不能满足最后一个老奶奶,然后出栈(为了变化top)

wa掉的/注意的:1.需要从最大到最小遍历,因为这样能知道确切的这个人是不是进的去进不去,这样一来需要思考的变化因素就很少,不用天南海北的进行纠结到底怎么选;2.其实这种做法有种第一次打电话就给所有的人打电话,从最后向前遍历,找到是不是真的可以满足,每个人都开心的进院子;3.一定出栈进行变换top;4.我不知道我为什么用sort就超时了,用优先队列就不超时

代码:

 1 #include<iostream>
2 #include<algorithm>
3 #include<cstdio>
4 #include<cmath>
5 #include<queue>
6 using namespace std;
7 int main(){
8 int t;
9 scanf("%d",&t);
10 while(t--){
11 int r,n;
12 scanf("%d",&n);
13 priority_queue<int> a;
14 for(int i=0;i<n;i++){
15 scanf("%d",&r);
16 a.push(r);
17 }
18 int s=0,m=n;
19
20 for(int i=0;i<n;i++){
21 if(a.top()<1+m){
22 s++;
23 }else{
24 m--;
25 }
26 a.pop();
27 }
28 printf("%d\n",s+1);
29 }
30 }

我实在是太菜了,导致我最近做的题不是很多,但是时间话得特别长,还是应该偶尔看看算法书,只靠思维题是不行了,而且有的思维题读题真的好麻烦,最近专业课落得好多,绝望!!!

05.24 ICPC 2019-2020 North-Western Russia Regional Contest复现赛+Codeforces Round #645 (Div. 2)的更多相关文章

  1. Codeforces Round #517 (Div. 2, based on Technocup 2019 Elimination Round 2)

    Codeforces Round #517 (Div. 2, based on Technocup 2019 Elimination Round 2) #include <bits/stdc++ ...

  2. 2017 ACM - ICPC Asia Ho Chi Minh City Regional Contest

    2017 ACM - ICPC Asia Ho Chi Minh City Regional Contest A - Arranging Wine 题目描述:有\(R\)个红箱和\(W\)个白箱,将这 ...

  3. Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2)

    A - Forgetting Things 题意:给 \(a,b\) 两个数字的开头数字(1~9),求使得等式 \(a=b-1\) 成立的一组 \(a,b\) ,无解输出-1. 题解:很显然只有 \( ...

  4. ICPC 2019-2020 North-Western Russia Regional Contest

    目录 Contest Info Solutions Problem A. Accurate Movement Problem B. Bad Treap Problem E. Equidistant P ...

  5. ICPC Central Russia Regional Contest (CRRC 19)题解

    题目连接:https://codeforces.com/gym/102780 寒假第二次训练赛,(某菜依旧是4个小时后咕咕咕),战况还行,个人表现极差(高级演员) A:Green tea 暴力枚举即可 ...

  6. Codeforces Round #268 (Div. 1) A. 24 Game 构造

    A. 24 Game Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/468/problem/A D ...

  7. Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) D. Power Products 数学 暴力

    D. Power Products You are given n positive integers a1,-,an, and an integer k≥2. Count the number of ...

  8. Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) C. p-binary 水题

    C. p-binary Vasya will fancy any number as long as it is an integer power of two. Petya, on the othe ...

  9. Codeforces Round #606 (Div. 2, based on Technocup 2020 Elimination Round 4) 题解

    Happy Birthday, Polycarp! Make Them Odd As Simple as One and Two Let's Play the Words? Two Fairs Bea ...

随机推荐

  1. 云原生的弹性 AI 训练系列之一:基于 AllReduce 的弹性分布式训练实践

    引言 随着模型规模和数据量的不断增大,分布式训练已经成为了工业界主流的 AI 模型训练方式.基于 Kubernetes 的 Kubeflow 项目,能够很好地承载分布式训练的工作负载,业已成为了云原生 ...

  2. 创建Maven父子项目以及它们的优点

    此文引用:https://blog.csdn.net/zxl8876/article/details/104180133 创建maven父子项目 第一步创建父项目: 新建一个普通的maven项目 删除 ...

  3. Android Studio中Switch控件有关 textOn 和 textOff 用法

    •属性 textOn:控件打开时显示的文字 textOff:控件关闭时显示的文字 showText:设置是否显示开关上的文字(API 21及以上) •用法 <?xml version=" ...

  4. Android Stuio让我濒临崩溃的bug之cause: unable to find valid certification path to requested target

    •问题描述 像往常一样,打开 $android studio$ 开启愉快的开发之旅: 写着写着,右下角弹出一个对话,说 $android studio$ 有新版本可更新: 有新版本为何不用,果断点击 ...

  5. 关于 下载 nfs-utils时的 gssproxy conflicts with selinux-policy-3.13.1-102.el7.noarch 错误

    使用 yum install nfs-utils -y 时 出现如下错误: 错误:gssproxy conflicts with selinux-policy-3.13.1-102.el7.noarc ...

  6. 1028 List Sorting

    Excel can sort records according to any column. Now you are supposed to imitate this function. Input ...

  7. Relatives(容斥)

    Relatives Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15708   Accepted: 7966 Descri ...

  8. 【ElasticSearch】文档路由的原理

    ElasticSearch集群环境下新增文档如何确认该文档被分配到哪个分片中? 路由算法: ⾸先这肯定不会是随机的,否则将来要获取⽂档的时候我们就不知道从何处寻找了.实际上,这个过程是根据下⾯这个公式 ...

  9. php 简易日志函数应用 debug_backtrace()

    1 public static function writeILogs($datas) 2 { 3 $bt = debug_backtrace(); 4 $caller = array_shift($ ...

  10. Android进程的so注入--Poison(稳定注入版)

    本文博客地址:http://blog.csdn.net/qq1084283172/article/details/53869796 Android进程的so注入已经是老技术了,网上能用的Android ...