前言
4月30号的2小时CF重现赛,基本都是DIV2的水题,目标是训练CF题目的题感来上分,主要是读英文题有困难,对题意理解困难…
比赛地址:https://cn.vjudge.net/contest/298841#status/499170967/H/0/
密码:wagv18
(CF的题复制过来根本没法读…没办法了,要看题目只能去原网址查看,以下有原网址)

A
Codeforces 1139B Chocolates
You went to the store, selling
n
n
types of chocolates. There are
a
i
ai
chocolates of type
i
i
in stock.
You have unlimited amount of cash (so you are not restricted by any prices) and want to buy as many chocolates as possible. However if you buy
x
i
xi
chocolates of type
i
i
(clearly,
0≤
x
i

a
i
0≤xi≤ai
), then for all
1≤j<i
1≤j<i
at least one of the following must hold:
x
j
=0
xj=0
(you bought zero chocolates of type
j
j
)
x
j
<
x
i
xj<xi
(you bought less chocolates of type
j
j
than of type
i
i
)
For example, the array
x=[0,0,1,2,10]
x=[0,0,1,2,10]
satisfies the requirement above (assuming that all
a
i

x
i
ai≥xi
), while arrays
x=[0,1,0]
x=[0,1,0]
,
x=[5,5]
x=[5,5]
and
x=[3,2]
x=[3,2]
don’t.
Calculate the maximum number of chocolates you can buy.
Input
The first line contains an integer
n
n
(
1≤n≤2⋅
10
5
1≤n≤2⋅105
), denoting the number of types of chocolate.
The next line contains
n
n
integers
a
i
ai
(
1≤
a
i

10
9
1≤ai≤109
), denoting the number of chocolates of each type.
Output
Print the maximum number of chocolates you can buy.
Examples
Input
Copy
5
1 2 1 3 6
Output
Copy
10
Input
Copy
5
3 2 5 4 10
Output
Copy
20
Input
Copy
4
1 1 1 1
Output
Copy
1
Note
In the first example, it is optimal to buy:
0+0+1+3+6
0+0+1+3+6
chocolates.
In the second example, it is optimal to buy:
1+2+3+4+10
1+2+3+4+10
chocolates.
In the third example, it is optimal to buy:
0+0+0+1
0+0+0+1
chocolates.
问题链接: http://codeforces.com/problemset/problem/1139/B
问题简述: 给定一个n长度的序列,每次买巧克力只能比前一次买巧克力的个数多,求最多能买多少个巧克力
问题分析: 贪心水过。从数组最后一个数据开始判断,如果上一个购买的个数比这个数数的还要小,就让ans加上这个值,如果大于等于这个数,就买这个数减一的巧克力数。
AC通过的C++语言程序如下:

#include <algorithm>
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <climits>
#include <iomanip>
#include <queue>
#include <map>
#include<vector>
#define ll long long
using namespace std;ll a[1000000];int main()
{ios::sync_with_stdio(false);int n;cin>>n;for(int i=1;i<=n;i++)cin>>a[i];ll ans=0;ll minn=999999999999;for(int i=n;i>0;i--){if(minn-1<a[i])minn=minn-1>0?minn-1:0;else minn=a[i];ans+=minn;}cout<<ans;return 0;
}

B
CodeForces - 1140A Detective Book

Ivan recently bought a detective book. The book is so interesting that each page of this book introduces some sort of a mystery, which will be explained later. The
i
i
-th page contains some mystery that will be explained on page
a
i
ai
(
a
i
≥i
ai≥i
).
Ivan wants to read the whole book. Each day, he reads the first page he didn’t read earlier, and continues to read the following pages one by one, until all the mysteries he read about are explained and clear to him (Ivan stops if there does not exist any page
i
i
such that Ivan already has read it, but hasn’t read page
a
i
ai
). After that, he closes the book and continues to read it on the following day from the next page.
How many days will it take to read the whole book?
Input
The first line contains single integer
n
n
(
1≤n≤
10
4
1≤n≤104
) — the number of pages in the book.
The second line contains
n
n
integers
a
1
,
a
2
,…,
a
n
a1,a2,…,an
(
i≤
a
i
≤n
i≤ai≤n
), where
a
i
ai
is the number of page which contains the explanation of the mystery on page
i
i
.
Output
Print one integer — the number of days it will take to read the whole book.
Example
Input
Copy
9
1 3 3 6 7 6 8 8 9
Output
Copy
4
Note
Explanation of the example test:
During the first day Ivan will read only the first page. During the second day Ivan will read pages number
2
2
and
3
3
. During the third day — pages
4
4

8
8
. During the fourth (and the last) day Ivan will read remaining page number
9
9
.
问题链接: http://codeforces.com/problemset/problem/1140/A
问题简述: 给定一个n的数列An,每天一定要读到第Ai页才能停下来,问多少天能读完
问题分析: 模拟水过,每天找到最大的页数,跳到那一天,累加天数,到终止条件退出即可。
AC通过的C++语言程序如下:

#include <algorithm>
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <climits>
#include <iomanip>
#include <queue>
#include <map>
#include<vector>
#define ll long long
using namespace std;int page[10000];int main()
{ios::sync_with_stdio(false);int n;cin>>n;for(int i=1;i<=n;i++){cin>>page[i];}int ans=0;for(int i=1;i<=n;i++){ans++;int maxx=page[i];int flag=0;for(int j=i;j<=maxx;j++){if(j==n){flag=1;break;}maxx=max(maxx,page[j]);}i=maxx;if(flag==1)break;}cout<<ans;return 0;
}

E
CodeForces - 1141A Game 23
Polycarp plays “Game 23”. Initially he has a number
n
n
and his goal is to transform it to
m
m
. In one move, he can multiply
n
n
by
2
2
or multiply
n
n
by
3
3
. He can perform any number of moves.
Print the number of moves needed to transform
n
n
to
m
m
. Print -1 if it is impossible to do so.
It is easy to prove that any way to transform
n
n
to
m
m
contains the same number of moves (i.e. number of moves doesn’t depend on the way of transformation).
Input
The only line of the input contains two integers
n
n
and
m
m
(
1≤n≤m≤5⋅
10
8
1≤n≤m≤5⋅108
).
Output
Print the number of moves to transform
n
n
to
m
m
, or -1 if there is no solution.
Examples
Input
120 51840
Output
7
Input
42 42
Output
0
Input
48 72
Output
-1
Note
In the first example, the possible sequence of moves is:
120→240→720→1440→4320→12960→25920→51840.
120→240→720→1440→4320→12960→25920→51840.
The are
7
7
steps in total.
In the second example, no moves are needed. Thus, the answer is
0
0
.
In the third example, it is impossible to transform
48
48
to
72
72
.
问题链接: http://codeforces.com/problemset/problem/1141/A
问题简述: 给定两个数a,b,a能乘与2或者3,求a到b要成2或3的次数,如果a不能转化到b,输出-1.
问题分析: 模拟水过,令k=a/b,如果k能被3整除,就让k一直除与3,如果能被2整除就一直除与2,如果最后k不等于1或者a无法被b整除,亦或者n>m,则输出-1,否则输出除3或2的次数即可
AC通过的C++语言程序如下:

#include <algorithm>
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <climits>
#include <iomanip>
#include <queue>
#include <map>
#include<vector>
#define ll long long
using namespace std;int main()
{ios::sync_with_stdio(false);int n,m;cin>>n>>m;int k=m/n;int ans=0;if(k%3==0){while(k%3==0){k/=3;ans++;}}if(k%2==0){while(k%2==0){k/=2;ans++;}}if(k!=1||n>m||m%n!=0)cout<<-1;else cout<<ans;return 0;
}

F
CodeForces - 1141B Maximal Continuous Rest
Each day in Berland consists of
n
n
hours. Polycarp likes time management. That’s why he has a fixed schedule for each day — it is a sequence
a
1
,
a
2
,…,
a
n
a1,a2,…,an
(each
a
i
ai
is either
0
0
or
1
1
), where
a
i
=0
ai=0
if Polycarp works during the
i
i
-th hour of the day and
a
i
=1
ai=1
if Polycarp rests during the
i
i
-th hour of the day.
Days go one after another endlessly and Polycarp uses the same schedule for each day.
What is the maximal number of continuous hours during which Polycarp rests? It is guaranteed that there is at least one working hour in a day.
Input
The first line contains
n
n
(
1≤n≤2⋅
10
5
1≤n≤2⋅105
) — number of hours per day.
The second line contains
n
n
integer numbers
a
1
,
a
2
,…,
a
n
a1,a2,…,an
(
0≤
a
i
≤1
0≤ai≤1
), where
a
i
=0
ai=0
if the
i
i
-th hour in a day is working and
a
i
=1
ai=1
if the
i
i
-th hour is resting. It is guaranteed that
a
i
=0
ai=0
for at least one
i
i
.
Output
Print the maximal number of continuous hours during which Polycarp rests. Remember that you should consider that days go one after another endlessly and Polycarp uses the same schedule for each day.
Examples
Input
5
1 0 1 0 1
Output
2
Input
6
0 1 0 1 1 0
Output
2
Input
7
1 0 1 1 1 0 1
Output
3
Input
3
0 0 0
Output
0
Note
In the first example, the maximal rest starts in last hour and goes to the first hour of the next day.
In the second example, Polycarp has maximal rest from the
4
4
-th to the
5
5
-th hour.
In the third example, Polycarp has maximal rest from the
3
3
-rd to the
5
5
-th hour.
In the fourth example, Polycarp has no rest at all.
问题链接: http://codeforces.com/problemset/problem/1141/B
问题简述: 给定只有0与1的序列n表示一个星期有n天,1代表该天可休息,求最长能够连续休息的天数。(最开始的天数与最后的天数是连续的)
问题分析: 模拟水过,开一个两倍大的数组,输入的时候令a[i+n]=a[i],再用一个循环找到最大天数即可
AC通过的C++语言程序如下:

#include <algorithm>
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <climits>
#include <iomanip>
#include <queue>
#include <map>
#include<vector>
#define ll long long
using namespace std;int k[1000000];int main()
{ios::sync_with_stdio(false);int n;cin>>n;for(int i=0;i<n;i++){cin>>k[i];k[i+n]=k[i];}int ans=0;int sum=0;for(int i=0;i<2*n;i++){if(k[i]==1){sum++;}else sum=0;ans=max(sum,ans);}cout<<ans;return 0;
}

H
CodeForces - 1139A Even Substrings
You are given a string
s=
s
1
s
2

s
n
s=s1s2…sn
of length
n
n
, which only contains digits
1
1
,
2
2
, …,
9
9
.
A substring
s[l…r]
s[l…r]
of
s
s
is a string
s
l
s
l+1
s
l+2

s
r
slsl+1sl+2…sr
. A substring
s[l…r]
s[l…r]
of
s
s
is called even if the number represented by it is even.
Find the number of even substrings of
s
s
. Note, that even if some substrings are equal as strings, but have different
l
l
and
r
r
, they are counted as different substrings.
Input
The first line contains an integer
n
n
(
1≤n≤65000
1≤n≤65000
) — the length of the string
s
s
.
The second line contains a string
s
s
of length
n
n
. The string
s
s
consists only of digits
1
1
,
2
2
, …,
9
9
.
Output
Print the number of even substrings of
s
s
.
Examples
Input
4
1234
Output
6
Input
4
2244
Output
10
Note
In the first example, the
[l,r]
[l,r]
pairs corresponding to even substrings are:
s[1…2]
s[1…2]
s[2…2]
s[2…2]
s[1…4]
s[1…4]
s[2…4]
s[2…4]
s[3…4]
s[3…4]
s[4…4]
s[4…4]
In the second example, all
10
10
substrings of
s
s
are even substrings. Note, that while substrings
s[1…1]
s[1…1]
and
s[2…2]
s[2…2]
both define the substring “2”, they are still counted as different substrings.
问题链接: http://codeforces.com/problemset/problem/1139/A
问题简述: 给定一个只有数字的string,求边界为偶数的子序列有多少个。
问题分析: 模拟水过,循环判断string的每个数字i是否为偶数,如果是偶数,则答案加上i,(有【1,i】,【2,i】,…,【i,i】一共i个序列)
AC通过的C++语言程序如下:

#include <algorithm>
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <climits>
#include <iomanip>
#include <queue>
#include <map>
#include<vector>
#define ll long long
using namespace std;char k[100000];int main()
{ios::sync_with_stdio(false);int n;cin>>n>>k;ll ans=0;for(int i=0;i<n;i++){if((k[i]-'0')%2==0)ans+=i+1;}cout<<ans;return 0;
}

2019.4.30 WAGV CF Team replay相关推荐

  1. 2019.07.30 学习整理

    2019.07.30 学习整理 数据类型 1. 什么是数据类型 数据类型指的就是变量值的不同类型 2. 为何对数据分类? 变量的是用来反映状态以及状态变化的,毫无疑问针对不同的状态就应该用不同类型的数 ...

  2. DayDayUp:2019.12.30吴晓波2020年终秀演讲《预见2020:来海边,拾起信心》读后有感

    DayDayUp:2019.12.30吴晓波2020年终秀演讲<预见2020:来海边,拾起信心>读后有感 导读:2019年,过的好不好?有人豪情万丈,有人强颜欢笑. 互联网平台带来了方便快 ...

  3. 18天精读掌握《费曼物理学讲义卷一》 第14天 2019/6/30

    18天精读掌握<费曼物理学讲义卷一> 第14天 2019/6/30 1. 18日掌握<费曼物理学讲义>卷一计划概览 2. 今日学习成果 3. 今日时间表 4.Atimelogg ...

  4. 15天精读掌握《高德纳:具体数学》 第4天 2019.5.30

    15天精读掌握<高德纳:具体数学> 第4天 2019/5.30 1. 15日掌握算法导论计划概览 2. 今日学习成果 3. 今日时间表 4.Atimelogger截图 今天是 2年修完清华 ...

  5. 【每日早报】2019/05/30

    每日早报 2019/05/30 国内要闻 文娱影游 科技通信 金融财经 住房地产 零售电商 汽车出行 汽车出行 教育培训 ##医疗健康 旅游民宿 国际视角 国内要闻 字节跳动回应"年内推出教 ...

  6. 2019/6/30,道歉书

    芳芳,对不起.首先我会和你道歉.因为在这件事上我是个不折不扣的无赖和混蛋. 然后我在好好和你说下这事情.从北京回来后,我们开始了一段恋情,在匆匆忙忙弄完了论文的东西后,我就开始张罗重新找工作的事情.因 ...

  7. 【2019.09.30】“福大同好”——原型设计展示~(软工实践第四次作业)

    [2019.09.29]更新:在页面的右侧新增了导航栏,方便阅读.评论区更新了背景图. [2019.09.30]更新:<构建之法>四五八章读后感:https://www.cnblogs.c ...

  8. PAT题集2019.5.30排名变动

    2019.5.30 团体天梯集 用户昵称 排名变动 总分变动 peterw 221 -> 175 1518 -> 1605 byl 214 -> 197 1525 -> 155 ...

  9. 美通社企业新闻汇总 | 2019.1.30 | 2019旅行者之选酒店榜发布;《小猪佩奇》动画迎“猪年”...

    要闻 俞敏洪在新东方年会发表演讲:2019,再次出发 361度宣布新晋世界拳王徐灿为品牌形象代言人 2019年旅行者之选全球酒店榜单发布,成都博舍获评中国最佳酒店 箩筐技术公司携中国位置,共建智慧交通 ...

最新文章

  1. MTU(最大传输单元)
  2. Java编写抓取用户信息代码_[代码全屏查看]-一个基于JAVA的知乎爬虫,抓取知乎用户基本信息...
  3. 编译linux内核分区,Ubuntu编译内核及grub的一些笔记
  4. Android框架式编程之BufferKnife
  5. Linux学习笔记15—RPM包的安装OR源码包的安装
  6. 幅值与峰峰值的计算_电厂振动测量、计算基础及汽轮机组振动标准!
  7. php日志数据统计,awk 进行php日志累计报错统计
  8. 统计数字字符个数(信息学奥赛一本通-T1129)
  9. rds for mysql的监控指标_支持的监控指标_云数据库 RDS_用户指南_MySQL用户指南_监控指标与告警_华为云...
  10. css 文字可选,在HTML5中如何使用CSS建立不可选的文字
  11. ajax——优化0126(增删改查:添加查看详情,返回结果类型为JSON型,在窗口显示)...
  12. iOS开发之跳转指定的tabbar控制器(二级页面跳转到指定的tabbar页面)
  13. 在面向服务的设计时有四个原则:
  14. PDF怎么转换成图片?这两种转换方法快速转换
  15. 给C语言程序设置密码
  16. vue3 tsx语法
  17. ubuntu14.04 有道辞典 安装成功后 打不开 的 解决办法
  18. 罗晨:梦想照进现实,一个独立开发者的田园诗
  19. SQLMAP-Tamper之较为通用的双写绕过
  20. SpringBoot 限流实现

热门文章

  1. 程序员节日的那些趣事与囧事!
  2. 如何破解极验滑动验证码?成功率 100%!
  3. 计算机软件安装程序,计算机软件安装 | ManageEngine Desktop Central
  4. Swing 组件嵌套组合自适应大小问题
  5. 一分钟了解阿里云产品:云监控
  6. [布什告别演讲].Presidential.Farewell.Speech.George.W.Bush.
  7. C语言课程设计学生籍贯信息,学生籍贯信息记录簿_C语言课程设计.doc
  8. 经典老歌:眼睛渴望眼睛的重逢
  9. 【771. 宝石与石头】
  10. 局域网交换机和路由器