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的更多相关文章

  1. codeforce #339(div2)C Peter and Snow Blower

    Peter and Snow Blower 题意:有n(3 <= n <= 100 000)个点的一个多边形,这个多边形绕一个顶点转动,问扫过的面积为多少? 思路:开始就认为是一个凸包的问 ...

  2. 「日常训练」Skills(Codeforce Round #339 Div.2 D)

    题意(CodeForces 614D) 每个人有\(n(n\le 10^5)\)个技能,技能等级都在\([0,10^9]\)的范围,每个技能有一个当前等级,所有技能的最高等级都为A.一个人的力量被记做 ...

  3. [codeforces 339]E. Three Swaps

    [codeforces 339]E. Three Swaps 试题描述 Xenia the horse breeder has n (n > 1) horses that stand in a ...

  4. [codeforces 339]D. Xenia and Bit Operations

    [codeforces 339]D. Xenia and Bit Operations 试题描述 Xenia the beginner programmer has a sequence a, con ...

  5. [codeforces 339]C. Xenia and Weights

    [codeforces 339]C. Xenia and Weights 试题描述 Xenia has a set of weights and pan scales. Each weight has ...

  6. Codeforce - Street Lamps

    Bahosain is walking in a street of N blocks. Each block is either empty or has one lamp. If there is ...

  7. Codeforces Round #339 (Div.2)

    A. Link/Cut Tree time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  8. Codeforce Round #216 Div2

    e,还是写一下这次的codeforce吧...庆祝这个月的开始,看自己有能,b到什么样! cf的第二题,脑抽的交了错两次后过了pretest然后system的挂了..脑子里还有自己要挂的感觉,果然回头 ...

  9. PEP Index > PEP 339 -- Design of the CPython Compiler 译文

    http://www.python.org/dev/peps/pep-0339/ PEP: 339 标题: CPython的编译器设计 版本: 425fc5598ee8 最后修改: 2011-01-1 ...

随机推荐

  1. 第六篇、微信小程序-form组件

    表单: 将组件内的用户输入的<switch/> <input/> <checkbox/> <slider/> <radio/> <pi ...

  2. Cocos2d-x中Vector<T>容器以及实例介绍

    Vector<T> 是Cocos2d-x 3.x推出的列表容器,因此它所能容纳的是Ref及子类所创建的对象指针,其中的T是模板,表示能够放入到容器中的类型,在Cocos2d-x 3.x中T ...

  3. requirejs实验001.对我来说,用AMD的方式来组织代码并不轻松.

    http://www.requirejs.org/ http://www.requirejs.cn/ http://requirejs.readthedocs.org/en/1.0.1/ 目录结构: ...

  4. 抓取dump

    1,在程序奔溃前部署.adplus.exe -crash -pn explorer.exe -o d: -crash:当进程挂掉的时候抓取dump,只能抓取到进程报错时的信息,如果进程不报错,就无法抓 ...

  5. QT编译mysql驱动

    一. 下载mysql C链接库 地址:http://dev.mysql.com/downloads/ 根据当前系统选择下载: 二. 安装下载好的mysql驱动文件 注意,一定要安装在不含有中文.空格以 ...

  6. C++ 宽字符(wchar_t)与窄字符(char)的转换

    了解 长度 宽字符wchar_t的长度16位,可以用来显示中文等除英文外的其他文字, 窄字符    char   的长度  8 位,只能处理英文. 哪里可以见到 在VS2010, 2012, 2013 ...

  7. Transact-SQL 存储过程(c#调用执行)

    1. Microsoft SQL Server Management Studio 中创建 存储过程 1.1 借助模板资源管理器中的Stored Procedure模板进行修改创建 1.2 直接新建查 ...

  8. C#定时器

    在C#里关于定时器类就有3个 1.定义在System.Windows.Forms里 2.定义在System.Threading.Timer类里 3.定义在System.Timers.Timer类里 S ...

  9. iOS Mac系统下Ruby环境安装

    由EasyIOS引出的一系列问题:转载的上一篇CocoaPods安装和使用教程中说明了,为什么要使用cocoapods ,但是要安装cocoapods需要Ruby环境,安装Ruby环境首先需要安装Xc ...

  10. python(三)一个文件读写操作的小程序

    我们要实现一个文件读写操作的小程序 首先我们有一个文件 我们要以"============"为界限,每一个角色分割成一个独立的txt文件,按照分割线走的话是分成 xiaoNa_1. ...