A

题意:给你一个01的字符串,0是个分界点,0把这个字符串分成(0的个数+1)个部分,分别求出这几部分1的个数。例如110011101 输出2031,100输出100,1001输出101

代码:

#include<stdio.h>
using namespace std;
int n;
char a[100];
int b[100];
int main()
{
while(~scanf("%d",&n))
{
scanf("%s",a);
int flag=0;
int k=0;
int cnt=0;
for(int i=0; i<n; i++)
{
if(a[i]=='1')
{
cnt++;
flag=0;
}
else
{
if(flag==0)
{
b[k++]=cnt;
flag=1;
cnt=0;
}
else if(flag==1)
{
b[k++]=0;
}
}
}
b[k++]=cnt;
for(int i=0; i<k; i++)
printf("%d",b[i]);
printf("\n");
}
return 0;
}

B

题意:五子棋,表示可以放旗子,x表示Alice的棋子,o是敌人的棋子,现在轮到Alice,问Alice是否能赢。

代码:

#include<stdio.h>
using namespace std;
char a[11][11];
int b,flag;
int main()
{
flag=0;
for(int i=0; i<10; i++)
scanf("%s",a[i]);
for(int i=0; i<10; i++)
for(int j=0; j<10; j++)
{
if(a[i][j]=='.')
{
b=0;
for(int k=i+1; (k<=i+5)&&k<10; k++)
if(a[k][j]=='X')
b++;
else
break;
for(int k=i-1; (k>=i-5)&&k>=0; k--)
if(a[k][j]=='X')
b++;
else
break;
if(b>=4)
flag=1;

b=0;
for(int k=j+1; (k<=j+5)&&k<10; k++)
if(a[i][k]=='X')
b++;
else
break;
for(int k=j-1; (k>=j-5)&&k>=0; k--)
if(a[i][k]=='X')
b++;
else
break;
if(b>=4)
flag=1;

b=0;
for(int k=1; k<=5; k++)
if((a[i+k][j+k]=='X')&&(i+k)<10&&(j+k)<10)
b++;
else
break;
for(int k=1; k<=5; k++)
if((a[i-k][j-k]=='X')&&(i-k)>=0&&(j-k)>=0)
b++;
else
break;
if(b>=4)
flag=1;

b=0;
for(int k=1; k<=5; k++)
if((a[i+k][j-k]=='X')&&(i+k)<10&&(j-k)>=0)
b++;
else
break;
for(int k=1; k<=5; k++)
if((a[i-k][j+k]=='X')&&(i-k)>=0&&(j+k)<10)
b++;
else
break;
if(b>=4)
flag=1;
if(flag==1)
break;
}
else
continue;
}
if(flag)
printf("YES\n");
else
printf("NO\n");
return 0;
}

C

题意:现在拥有的困难数为k,如果a[i]/2<=k,表示这个问题可以解决,如果啊a[i]>k/2则k*=2,直到a[i]<=k/2,并且k=max(k,a[i]),问k*=2的总次数,使得所有的a[i]<=k/2。

代码:

#include<stdio.h>
#include<algorithm>
using namespace std;
int n;
double m;
double a[1100];
int main()
{
while(~scanf("%d%lf",&n,&m))
{
for(int i=0; i<n; i++)
scanf("%lf",&a[i]);
sort(a,a+n);
double k=m;
int cnt=0;
for(int i=0; i<n; i++)
{
if(a[i]/2.0<=k)
{
k=max(k,a[i]);
continue;
}
else
{
while(1)
{
k*=2;
cnt++;
if(a[i]/2.0<=k)
break;
}
}
k=max(k,a[i]);
}
printf("%d\n",cnt);
}
return 0;
}

Educational Codeforces Round 25的更多相关文章

  1. Educational Codeforces Round 25 E. Minimal Labels&&hdu1258

    这两道题都需要用到拓扑排序,所以先介绍一下什么叫做拓扑排序. 这里说一下我是怎么理解的,拓扑排序实在DAG中进行的,根据图中的有向边的方向决定大小关系,具体可以下面的题目中理解其含义 Educatio ...

  2. Educational Codeforces Round 25 Five-In-a-Row(DFS)

    题目网址:http://codeforces.com/contest/825/problem/B 题目:   Alice and Bob play 5-in-a-row game. They have ...

  3. Educational Codeforces Round 25 A,B,C,D

    A:链接:http://codeforces.com/contest/825/problem/A 解题思路: 一开始以为是个进制转换后面发现是我想多了,就是统计有多少个1然后碰到0输出就行,没看清题意 ...

  4. Educational Codeforces Round 25 C. Multi-judge Solving

    题目链接:http://codeforces.com/contest/825/problem/C C. Multi-judge Solving time limit per test 1 second ...

  5. Educational Codeforces Round 25 B. Five-In-a-Row

    题目链接:http://codeforces.com/contest/825/problem/B B. Five-In-a-Row time limit per test 1 second memor ...

  6. Educational Codeforces Round 25 E. Minimal Labels 拓扑排序+逆向建图

    E. Minimal Labels time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  7. Educational Codeforces Round 25 D - Suitable Replacement(贪心)

    题目大意:给你字符串s,和t,字符串s中的'?'可以用字符串t中的字符代替,要求使得最后得到的字符串s(可以将s中的字符位置两两交换,任意位置任意次数)中含有的子串t最多. 解题思路: 因为知道s中的 ...

  8. [Educational Codeforces Round 16]E. Generate a String

    [Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file f ...

  9. Educational Codeforces Round 60 (Rated for Div. 2) 题解

    Educational Codeforces Round 60 (Rated for Div. 2) 题目链接:https://codeforces.com/contest/1117 A. Best ...

随机推荐

  1. django之组件

    (Django) 组件:本质上就是将一个写好的功能模块的html文件直接引入html目标文件,利用其功能. 标准语法: {% include 'html文件名' %} 如:{% include 'na ...

  2. centos7更改时区

    1,linux系统更换时区 2,时间同步 1,linux系统更换时区 注:# timedatectl # 查看系统时间方面的各种状态 # timedatectl list-timezones # 列出 ...

  3. hdu 3065 AC自动机 标记数组不清零

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3065 题目里面要我们计算每种单词出现的次数,重叠的也要计算,那么我们在查找的时候不要把标记单词结尾的 ...

  4. mysql数据库优化之 如何选择合适的列建立索引

    1. 在where 从句,group by 从句,order by 从句,on 从句中出现的列: 2. 索引字段越小越好: 3. 离散度大的列放到联合索引的前面:比如: select * from p ...

  5. 登录界面,body上有背景图,点击输入框时,弹出的手机键盘会把背景图顶变形,而且会把footer顶上去

    js: //防止背景图被手机键盘压缩变形 $(document).ready(function () { $('body').css({'height':$(window).height()}) }) ...

  6. vue.js 进行初始化遇到的关于core-js的错误@core-js/modules/es6.array.find-index]

    D:\vuejselement\workSpace\zutnlp_platform_show>cnpm install --save core-js/modules/es6.array.find ...

  7. .NET Core 微服务实例

    关于微服务,MSDN给出了定义和架构图:https://docs.microsoft.com/zh-cn/azure/architecture/guide/architecture-styles/mi ...

  8. 安装mitmproxy

    https://www.jianshu.com/p/1dd40826113b 先连接到同一个局域网,再访问官网下载描述文件

  9. php 随机生成ip

    #随机生成IP 中国区 function randip(){ $ip_1 = -1; $ip_2 = -1; $ip_3 = rand(0,255); $ip_4 = rand(0,255); $ip ...

  10. ----regular expression in js----

    正则表达式:Regular Expression,在代码中常简写为regex.regexp或RE)使用单个字符串来描述.匹配一系列符合某个句法规则的字符串搜索模式. 搜索模式可用于文本搜索和文本替换. ...