A

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 105
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
char s[N];
int main()
{
int i,j,k;
cin>>s;
k = strlen(s);
int ans = ,g=;
for(i = ; i < k ;i++)
{
if(s[i]!=s[i-])
{
g = ;
ans++;
}
else g++;
if(g>)
{
g = ;
ans++;
}
//cout<<ans<<" "<<g<<" "<<s[i]<<endl;
}
cout<<ans<<endl;
return ;
}

B

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 5050
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
int a[N],f[N];
int main()
{
int i,j,n,k;
cin>>n;
for(i =;i <= n; i++)cin>>a[i];
for(i = ;i <= n ;i++)
{
f[a[i]] = ;
}
int ans=;
for(i = ; i<= n; i++)
if(!f[i]) ans++;cout<<ans<<endl;
return ;
}

C

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 100010
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
struct node
{
int x,y;
}p[N];
bool cmp(node a,node b)
{
return a.x<b.x;
}
int main()
{
int i,j,n;
cin>>n;
for(i = ; i <= n ;i++)
cin>>p[i].x>>p[i].y;
sort(p+,p+n+,cmp);
int mm = ,ans=;
for(i = ; i <= n ;i ++)
{
if(p[i].y<mm)
ans++;
mm = max(mm,p[i].y); }
cout<<ans<<endl;
return ;
}

D

dp  先预处理出来i-j距离回文串所差的步数  然后D出1-k所需最少的步数 记录一下路径 最后输出

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 505
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
char s[N];
int dp[][],o[][],e[][];
int p[];
int dfs(int i,int j)
{
int a,b;
int o1 = ;
int ii = i,jj = j;
while(ii<jj)
{
if(s[ii]!=s[jj]) o1++;
ii++,jj--;
}
return o1;
}
int main()
{
int i,j,n,kk,k,g;
for(i = ;i <= ; i++)
for(j = ; j <= ; j++)
dp[i][j] = INF;
cin>>s;
kk = strlen(s);
cin>>k;
for(i = ;i < kk ;i++)
for(j = i ; j < kk ;j++)
o[i][j] = dfs(i,j);
for(i = ; i < kk; i++)
{
dp[i][] = o[][i];
}
for(i = ;i < kk ;i++)
for(j = ; j <= min(i+,k) ; j++)
for(g = ; g < i ; g++)
{
if(dp[i][j]>dp[g][j-]+o[g+][i])
{
dp[i][j] = dp[g][j-]+o[g+][i];
e[i][j] = g;
}
}
int minz = INF,x;
for(i = ; i <= k ;i++)
{
if(minz>dp[kk-][i])
{
minz = dp[kk-][i];
x = i;
}
}
cout<<minz<<endl;
if(x==)
{
for(i = ; i < kk/ ; i++)
printf("%c",s[i]);
for(i = (kk-)/ ; i >= ; i--)
printf("%c",s[i]);
return ;
}
g = ;
int ki = kk-;
while(x!=)
{
ki = e[ki][x];
p[g++] = ki;
x--;
}
sort(p,p+g);
for(i = ;i <= p[]/ ; i++)
printf("%c",s[i]);
if(p[])
{
for(i = (p[]-)/ ; i >= ; i--)
printf("%c",s[i]);
}
for(i = ; i < g- ;i++)
{
printf("+");
for(j = p[i]+ ;j <= p[i]+(p[i+]-p[i]+)/ ; j++)
cout<<s[j];
for(j = p[i]+(p[i+]-p[i])/ ;j >= p[i]+ ; j--)
cout<<s[j];
}
if(p[g-]+<kk)
printf("+");
for(i = p[g-]+ ; i <= p[g-]+(kk-p[g-])/ ; i++)
cout<<s[i];
for(i = p[g-]+(kk-p[g-]-)/ ; i >= p[g-]+ ; i--)
cout<<s[i];
cout<<endl;
return ;
}

E

元音-1 辅音+2 开数组sum[i]存前i项和  也就是找最大段(i,j)使sum[j]-sum[i]>=0

这样只存下降的sum数组即可  因为上升的的某个g事不需要的 二分查找第一个小于等于sun[i]的位置 取最大

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 200010
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
char s[N];
int sum[N];
struct node
{
int a,po;
}p[N];
int bfind(int l,int h,int k)
{
int m;
while(l<h)
{
m = (l+h)>>;
if(p[m].a<k)
h = m;
else if(p[m].a>k)
l = m+;
else return p[m].po;
}
return p[l].po;
}
int judge(char c)
{
if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
return ;
if(c=='A'||c=='E'||c=='I'||c=='O'||c=='U')
return ;
return ;
}
int main()
{
int i,j,k;
cin>>s;
k = strlen(s);
int g = ;
for(i = ; i < k ;i++)
{
if(i==)
{
if(judge(s[i]))
sum[] = -;
else
sum[] = ;
p[++g].a = sum[i];
p[g].po = i;
}
else
{
if(judge(s[i]))
sum[i] = sum[i-]-;
else
sum[i] = sum[i-]+;
if(sum[i]<p[g].a)
{
p[++g].a = sum[i];
p[g].po = i;
}
}
}
int ans=,cnt=;
for(i = ; i < k ;i++)
{
if(sum[i]>=)
{
ans = i+;
cnt = ;
}
else
{
int o = i-bfind(,g,sum[i]);
//cout<<o<<" "<<i<<" "<<bfind(1,g,sum[i])<<endl;
if(o>ans)
{
ans = o;
cnt = ;
}
else if(o==ans)
cnt++;
}
}
if(ans)
cout<<ans<<" "<<cnt<<endl;
else
puts("No solution");
return ;
}

Codeforces Beta Round #98 (Div. 2)(A-E)的更多相关文章

  1. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  2. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  3. Codeforces Beta Round #79 (Div. 2 Only)

    Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...

  4. Codeforces Beta Round #77 (Div. 2 Only)

    Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...

  5. Codeforces Beta Round #76 (Div. 2 Only)

    Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...

  6. Codeforces Beta Round #75 (Div. 2 Only)

    Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...

  7. Codeforces Beta Round #74 (Div. 2 Only)

    Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...

  8. Codeforces Beta Round #73 (Div. 2 Only)

    Codeforces Beta Round #73 (Div. 2 Only) http://codeforces.com/contest/88 A 模拟 #include<bits/stdc+ ...

  9. Codeforces Beta Round #72 (Div. 2 Only)

    Codeforces Beta Round #72 (Div. 2 Only) http://codeforces.com/contest/84 A #include<bits/stdc++.h ...

随机推荐

  1. Asp.net MVC 简单分页 自做简单分页

    Asp.net MVC 简单分页:   public static string Pager(int page,int pageSize,int total)         {           ...

  2. LoadRunner 事务响应时间的组成

    事务时间 一个事务的时间是指持续时间,事务会完全记录下从事务开始到事务结束之间的时间差,那么事务的时间能真实地反映业务操作的时间吗?不能,就好像人用手按秒表来记录短跑时间一样,得出的时间并不是完全准确 ...

  3. Linux文件系统与磁盘管理

    Linux文件系统与磁盘管理 有哪些文件系统: FAT:微软在Dos/Windows系列操作系统中共使用的一种文件系统的总称.       exFAT(Extended File Allocation ...

  4. Coding Ninja 修炼笔记 (1)

    大家好啊~我又回来了. 这次主要是给大家带来一些提升 Coding 效率的建议. 效率都是一点一滴优化出来的,虽然每一条建议给你带来的提升可能都不大,但是积累起来,仍然是一股不可忽视的力量. 第一条 ...

  5. phpqrcode生成带logo的二维码图片及带文字的二维码图片

    <?php require_once "./phpqrcode/phpqrcode.php"; /** * 这样就可以生成二维码了,实际上在png这个方法里还有几个参数需要使 ...

  6. OpenGL的版本号历史和发展

    来源请注明.本文永久地址为http://www.cnblogs.com/vertexshader/articles/2917540.html OpenGL®作为业界最为广泛使用的2D和3D图形接口标准 ...

  7. mysql16---读写分离

    读写分离(负载平衡)(读写分离肯定要用到主从复制) 如果数据库压力很大,一台机器支撑不了,那么可以用mysql复制实现多台机器同步,将数据库的压力分散. 分表不能解决并发量大的问题. Sql语句发过来 ...

  8. POJ1177 Picture —— 求矩形并的周长 线段树 + 扫描线 + 离散化

    题目链接:https://vjudge.net/problem/POJ-1177 A number of rectangular posters, photographs and other pict ...

  9. YTU 1098: The 3n + 1 problem

    1098: The 3n + 1 problem 时间限制: 1 Sec  内存限制: 64 MB 提交: 368  解决: 148 题目描述 Consider the following algor ...

  10. 用过滤器Filter判断用户是否登陆

    用过滤器Filter判断用户是否登陆 WEB.XML <!-- 用户session的 键   sessionKEY --> <context-param> <param- ...