http://acm.zju.edu.cn/onlinejudge/showContestProblems.do?contestId=392

E:Sequence in the Pocket

思路:从后往前判断在不在应该在的位置,如果不在则需要放到最前面,通过cnt控制当前的数 比较 排好序的数组的数。

code:

#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define INF 2000000000
#define eps 1e-8
#define pi 3.141592653589793
int a[],b[];
int main()
{
int t;scanf("%d",&t);
while(t--) {
int n ,cnt = ;scanf("%d",&n);
for(int i = ; i < n; i++) {
scanf("%d",&a[i]);
b[i] = a[i];
}
sort(b,b+n);
for(int i = n-1; i >= ; i--) {
if(a[i] != b[i+cnt]) cnt++;
}
printf("%d\n",cnt);
}
}

F:Abbreviation

思路:无

code:

#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define INF 2000000000
int main(){
LL n;cin>>n;
while(n--){
string s,ans="";
cin>>s;
for(int i = ; i < s.size() ; i++){
if(i == ){
ans += s[i];
}else{
if(s[i] != 'a' && s[i] != 'e' && s[i] != 'o'&& s[i] != 'i'&& s[i] != 'y'&& s[i] != 'u'){
ans += s[i];
}
}
}
cout<<ans<<endl;
}
return ;
}
/*
5
subconscious
oipotato
word
symbol
apple
*/

G:Lucky 7 in the Pocket

思路:

记当前这个数为n,则(n/7+(n%7==0)?0:1)*7 ,则表示大于等于这个数切能被7整除的数。

再判断一下是不是4的倍数就行了,如果是则答案是(n/7+(n%7==0)?1:2)*7

#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define INF 2000000000
int main(){
LL n;cin>>n;
while(n--){
LL m;cin>>m;
LL k = m/ + (m%==?:);
cout<<(((k*7LL)%)==?((k+1LL)*7LL):(k*7LL))<<endl;
}
return ;
}
/*
7
1235
20
28
*/

H:Singing Everywhere

思路:各种判断

情况分为2种

1、如果有1 3 2 3 1这种,考虑删除两个峰值之间的这个2

2、考虑删除峰值

反正对答案影响肯定是-0,-1,-2。三种情况,大力推就行

code:

#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define INF 2000000000
#define eps 1e-8
#define pi 3.141592653589793
int a[];
int cnt[];
int main()
{
int t;
scanf("%d",&t);
while(t--){
int n;
memset(cnt,,sizeof(cnt));
scanf("%d",&n);
for(int i = ; i < n ; i++){
scanf("%d",&a[i]);
}
if(n == ||n == ){
puts("");
} // n==1 or n==2 不用做操作的
else{
int sum = ,f = ,f1 = ;
if(a[] < a[]) cnt[]++;
if(a[n-] < a[n-]) cnt[n-]++;
//考虑到可能可以删除 1 or n-1
for(int i = ; i < n- ; i++){
if(a[i]>a[i-] && a[i]>a[i+]){
sum++;
if((a[i-] < a[i+] && (i+==n ||a[i+] <= a[i+]) )|| a[i-]==a[i+] ){
f1 = ;
}//删除峰值
cnt[i-]++;
cnt[i+]++;
}
}
//cnt增加峰值旁边的两个数,考虑情况1
for(int i = ; i < n- ; i++){
if(cnt[i] == ){
if(a[i-] == a[i+]){
f = max(f,);
}
else if(a[i-] < a[i+]){
f = max(f,);
}
else if(a[i-] > a[i+]){
if((i-==) || a[i-]>=a[i-]){
f = max(f,);
}
}
}
}
if(f){
printf("%d\n",sum-f);continue;
}
printf("%d\n",sum-f1);
}
}
}
/*
5
6
1 1 4 5 1 4
6
1 1 4 7 5 5
6
1 1 4 7 5 4
7
3 1 5 4 5 1 7
7
1 2 3 4 5 1 7 2
2
1 2
7
1 3 3 3 3 3 1
*/

I:Fibonacci in the Pocket

思路:

斐波那契数列 写一下前几项就知道是 奇奇偶 奇奇偶 奇奇偶 奇奇偶....

循环节是3。

另外一个性质是,一个数%3,等于这个数各个位数的和%3

既然是求和

考虑起点和终点吧,起点为a 终点为b,利用性质可以很方便算出a%3 和 b%3的值

那么就知道了,起点位于循环节的第几个,终点位于循环节的第几个。

分类讨论一下就知道和是奇数还是偶数。

#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define INF 2000000000
#define eps 1e-8
#define pi 3.141592653589793
int main()
{
int t;
scanf("%d",&t);
while(t--){
string a,b;
cin>>a>>b;
int s1 = ,s2 = ;
for(int i = ; i < a.size() ; i ++){
s1+=(a[i]-'');s1%=;
}
for(int i = ; i < b.size() ; i ++){
s2+=(b[i]-'');s2%=;
}
if((s1+s2)%== || s1== && s2== || s1==&&s2==){
puts("");
}//都位于循环节末尾或者起点在0 终点在2 或者起点在1终点在0
else{
puts("");
}
}
}
/*
6
1 2
1 3
1 4
1 5
123456 12345678987654321
123 20190427201904272019042720190427
*/

The 16th Zhejiang Provincial Collegiate Programming Contest Sponsored(E F G H I)的更多相关文章

  1. The 16th Zhejiang Provincial Collegiate Programming Contest Sponsored E.Sequence in the Pocket(思维题)

    传送门 题意: 给出一个序列,你可以将任意一个数移到最前面: 求最少需要移动多少次,可以是此序列变成非递减序列: 思路: 定义 (ai,aj) 为逆序对 ( i < j , ai > aj ...

  2. The 16th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple (Mirror)

    B题 思路 因为 \[ x=\sum\limits_{k=1}^{n}ka_k\\ y=\sum\limits_{k=1}^{n}ka_{k}^{2} \] 我们设交换前和交换后的这两个等式的值设为\ ...

  3. The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - L Doki Doki Literature Club

    Doki Doki Literature Club Time Limit: 1 Second      Memory Limit: 65536 KB Doki Doki Literature Club ...

  4. 2018浙江省赛(ACM) The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple

    我是铁牌选手 这次比赛非常得爆炸,可以说体验极差,是这辈子自己最脑残的事情之一. 天时,地利,人和一样没有,而且自己早早地就想好了甩锅的套路. 按理说不开K就不会这么惨了啊,而且自己也是毒,不知道段错 ...

  5. The 16th Zhejiang provincial collegiate programming contest

    今天我挺有状态的,看过的题基本都给了正解(可能是昨晚cf div3打得跟屎一样,人品守恒,不好意思发题解了),自己也给队伍签了很多水题(不敢让队友写,怕出锅). 最后6题滚了,有点可惜.还差B和K没做 ...

  6. The 14th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - F 贪心+二分

    Heap Partition Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge A sequence S = { ...

  7. The 14th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - C 暴力 STL

    What Kind of Friends Are You? Time Limit: 1 Second      Memory Limit: 65536 KB Japari Park is a larg ...

  8. The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - M Lucky 7

    Lucky 7 Time Limit: 1 Second      Memory Limit: 65536 KB BaoBao has just found a positive integer se ...

  9. The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - J CONTINUE...?

    CONTINUE...? Time Limit: 1 Second      Memory Limit: 65536 KB      Special Judge DreamGrid has  clas ...

随机推荐

  1. 借助ssh隧道和中间主机,使本地主机可以直连远程主机

    本地主机:    localhost 中间主机:   kickstart服务器 10.164.229.162 远程主机:   fuel 服务器  192.168.0.11 背景:正常情况下,本地不能直 ...

  2. JS代码简单一段即可破解QQ空间删除说说

    代码如下: 简单的一段代码即可搞定啦!!是不是很简单! var delay = 1000; function del() { document.querySelector('.app_canvas_f ...

  3. zookeeper的读写流程

    zookeeper的读写流程 基本架构 节点数要求是奇数. 常用的接口是 get/set/create/getChildren. 读写流程 写流程 客户端连接到集群中某一个节点 客户端发送写请求 服务 ...

  4. Winfrom中的几种传值方式

    1.最常见的一种, 不知道你们是否记得构造函数,当然这是对有点基础的人说的, 再我们申明一个类的时候,可能很多时候都不会注意,因为会我们的编辑器自带会默认生成一个不带参数的构造函数, 所以不在意,但是 ...

  5. C语言,链表操作

    #include "stdafx.h" #include <stdio.h> #include <stdlib.h> #include <string ...

  6. python if,循环的练习

    1.变量值的交换 ​ s1='alex'​ s2='SB' (s1,s2) = (s2,s1) 2.有存放用户信息的列表如下,分别存放用户的名字.年龄.公司信息 userinfo={ 'name':' ...

  7. py库:numpy

    http://www.numpy.org/ numpy官网 http://cwiki.apachecn.org/pages/viewpage.action?pageId=10030181 scikit ...

  8. Java2E中的路径问题

    本节主要介绍: 1.request.getContextPath()-----项目的发布的根路径 2.request.getRealPath('t')----t目录在当前磁盘中的物理位置,包括盘符,文 ...

  9. 一行js代码识别Selenium+Webdriver及其应对方案

    有不少朋友在开发爬虫的过程中喜欢使用Selenium + Chromedriver,以为这样就能做到不被网站的反爬虫机制发现. 先不说淘宝这种基于用户行为的反爬虫策略,仅仅是一个普通的小网站,使用一行 ...

  10. H5使用codovar插件实现支付宝支付(支付宝APP支付模式,前端)

    H5打包的app实现支付及支付宝支付,本章主要详解支付宝支付,微信支付请查看另一篇“H5使用codovar插件实现微信支付(微信APP支付模式,前端)” ps:本文只试用H5开发的,支付宝 APP支付 ...