CodeForce 339:A+B+C
A题:水题。。
#include<stdio.h>
#include<string.h>
const int maxn = ;
char s[ maxn ];
int main(){
//freopen("in.txt","r",stdin);
while( scanf("%s",s)!=EOF ){
int len = strlen(s);
int c1 = ,c2 = ,c3 = ;
for( int i=;i<len;i++ ){
if( s[i]=='' ) c1++;
if( s[i]=='' ) c2++;
if( s[i]=='' ) c3++;
}
int sum = c1+c2+c3;
if( sum== ){
printf("%s\n",s);
continue;
}
for( int i=;i<sum;i++ ){
if( i== ){
if( c1 ) printf(""),c1--;
else if( c2 ) printf(""),c2--;
else if( c3 ) printf(""),c3--;
}
else{
if( c1 ) printf("+1"),c1--;
else if( c2 ) printf("+2"),c2--;
else if( c3 ) printf("+3"),c3--;
}
}
printf("\n");
}
return ;
}
B题:还是水题。。模拟。。
#include<stdio.h>
const int maxn = ;
typedef long long LL;
LL a[ maxn ];
int main(){
int n,m;
//freopen("in.txt","r",stdin);
while( scanf("%d%d",&n,&m)== ){
for( int i=;i<=m;i++ ){
scanf("%I64d",&a[i]);
}
LL sum = ;
for( int i=;i<=m;i++ ){
if( i== ){
sum += a[i]-;
}
else {
if( a[i]>=a[i-] ) sum += (a[i]-a[i-]);
else sum += (n+a[i]-a[i-]);
}
}
printf("%I64d\n",sum);
}
return ;
}
C题:简单的DFS,满足两个条件即可。。。
题意别理解错!!!!!!!!!!!!!!!!!
#include<stdio.h>
#include<string.h>
const int maxn = ;
int ans[ maxn ];
//int cnt ;
char str[ maxn ];
int m;
bool ok; void dfs( int L,int R,int sL,int sR,int cnt ){
if( cnt==m&&ok==false ){
ok = true;
return ;
}
if( ok==true ) return ;
for( int i=;str[i]!='\0';i++ ){
if( str[i]=='' ){
if( cnt%==&&((i+)!=R)&&(sL+i+>sR) ){
ans[ cnt ] = i+;
dfs( i+,R,sL+i+,sR,cnt+ );
}
if( ok==true ) return ;
if( cnt%==&&((i+)!=L)&&(sR+i+>sL) ){
ans[ cnt ] = i+;
dfs( L,i+,sL,sR+i+,cnt+ );
}
if( ok==true ) return ;
}
}
return;
} int main(){
//freopen("in.txt","r",stdin);
scanf("%s%d",str,&m);
ok = false;
if( m== ){
for( int i=;str[i]!='\0';i++ ){
if( str[i]=='' ){
ok = true;
printf("YES\n%d\n",i+);
break;
}
}
if( ok==false ) printf("NO\n");
return ;
}
ok = false;
dfs( ,,,, );
if( ok==true ){
puts("YES");
for( int i=;i<m;i++ ){
if( i== ) printf("%d",ans[i]);
else printf(" %d",ans[i]);
}
printf("\n");
}
else puts("NO"); return ;
}
CodeForce 339:A+B+C的更多相关文章
- codeforce #339(div2)C Peter and Snow Blower
Peter and Snow Blower 题意:有n(3 <= n <= 100 000)个点的一个多边形,这个多边形绕一个顶点转动,问扫过的面积为多少? 思路:开始就认为是一个凸包的问 ...
- 「日常训练」Skills(Codeforce Round #339 Div.2 D)
题意(CodeForces 614D) 每个人有\(n(n\le 10^5)\)个技能,技能等级都在\([0,10^9]\)的范围,每个技能有一个当前等级,所有技能的最高等级都为A.一个人的力量被记做 ...
- [codeforces 339]E. Three Swaps
[codeforces 339]E. Three Swaps 试题描述 Xenia the horse breeder has n (n > 1) horses that stand in a ...
- [codeforces 339]D. Xenia and Bit Operations
[codeforces 339]D. Xenia and Bit Operations 试题描述 Xenia the beginner programmer has a sequence a, con ...
- [codeforces 339]C. Xenia and Weights
[codeforces 339]C. Xenia and Weights 试题描述 Xenia has a set of weights and pan scales. Each weight has ...
- Codeforce - Street Lamps
Bahosain is walking in a street of N blocks. Each block is either empty or has one lamp. If there is ...
- Codeforces Round #339 (Div.2)
A. Link/Cut Tree time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...
- Codeforce Round #216 Div2
e,还是写一下这次的codeforce吧...庆祝这个月的开始,看自己有能,b到什么样! cf的第二题,脑抽的交了错两次后过了pretest然后system的挂了..脑子里还有自己要挂的感觉,果然回头 ...
- PEP Index > PEP 339 -- Design of the CPython Compiler 译文
http://www.python.org/dev/peps/pep-0339/ PEP: 339 标题: CPython的编译器设计 版本: 425fc5598ee8 最后修改: 2011-01-1 ...
随机推荐
- Cocos开发中性能优化工具介绍之Visual Studio内存泄漏检测工具——Visual Leak Detector
那么在Windows下有什么好的内存泄漏检测工具呢?微软提供Visual Studio开发工具本身没有什么太好的内存泄漏检测功能,我们可以使用第三方工具Visual Leak Detector(以下简 ...
- AjaxFileUpload 在C#中应用
一.前台页面 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head ru ...
- 【HTML 5或CSS3入门教程】找兼职撰写人才
出版社要出版一套HTML 5和CSS 3方向的图书,目前急缺两名写作人员,要求1.熟悉CSS 3的各种属性,或熟悉HTML 5框架2.熟悉各种CSS代码,或熟悉各种HTML 5代码3.有写作的兴趣爱好 ...
- mysql 之路目录
数据库介绍.常见分类 Mysql入门 Mysql安装配置 Mysql多实例安装配置 Mysql常用基本命令 Mysql数据库备份和恢复 Mysql日志 Mysql逻辑.物理备份和增量恢复 Mysql字 ...
- js中 在数组中删除重复的元素(自保留一个)
例如:var student = [‘qiang’,’ming’,’tao’,’li’,’liang’,’you’,’qiang’,’tao’]; 第一种思路是:遍历要删除的数组arr, 把元素分别放 ...
- Mac OS X安装OpenCV 3.1.0
在我的上一篇文章“”中已经介绍了Linux下OpenCV的安装配置方法,在这里仅仅记录Mac上相对于Linux的一点点差异. 1. 安装依赖包 Mac上安装软件包使用的工具是brew,用此来替代Ubu ...
- 深度优先算法DFS
英雄要从H点出发,去解救位于M点的美女. 迷宫的围墙用#表示,带*号的位置表示有杀手埋伏,这些点都是不能走的, 那么英雄要最少走多少步才能解救美女呢? package myalgorithm; imp ...
- NGINX+UWSGI 莫名发生Nginx 502 Bad Gateway错误的排查过程
自己有个阿里云UBUNTU运行的Django站,使用NGINX+UWSGI驱动,今天登陆系统后台更新内容出现了几个大字:Nginx 502 Bad Gateway,一看情况不好,这是要糟糕啊. 啊西八 ...
- Building microservices with Spring Cloud and Netflix OSS, part 2
In Part 1 we used core components in Spring Cloud and Netflix OSS, i.e. Eureka, Ribbon and Zuul, to ...
- Linux定时任务crontab每三秒执行一次shell
第一种方法:当然首先想到的是写一个触发的脚本,在触发脚本中使用死循环来解决此问题,如下: cat kick.sh #!/bin/bash while : ;do /home/somedir/scrip ...