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 ...
随机推荐
- Cocos2d-x内置粒子系统
从类图中我们可以看到,Cocos2d-x中有内置的11粒子,这些粒子的属性都是预先定义好的,我们也可以在程序代码中单独修改某些属性,我们在上一节的实例中都已经实现了这些属性的设置. 内置粒子系统 内置 ...
- 采用HttpModules来重写URLS
首先写一个处理URLs重写的类,并且这个类必须继承IHttpHandler接口,以博客园的程序为例: public class UrlReWriteModule : System.Web.IHttpM ...
- 关于remote访问中的flex端配置问题
刚刚开始使用blazeds可能会有个疑问.tomcat服务器是必须配置的吗?如果前台后台分开,怎么开发. 其实服务器不是必须配置的,配置了那个服务器,就会在“附加编译参数”加入这样一句: -servi ...
- Windows下Android模拟环境的搭建
- Trie树入门及训练
什么叫Trie树? Trie树即字典树. 又称单词查找树,Trie树,是一种树形结构,是一种哈希树的变种.典型应用是用于统计,排序和保存大量的字符串(但不仅限于字符串),所以经常被搜索引擎系统用于文本 ...
- Poj 3030 Nasty Hacks
1.Link: http://poj.org/problem?id=3030 2.Content: Nasty Hacks Time Limit: 1000MS Memory Limit: 655 ...
- SQL Server 收缩事务日志的方法
由于SQL2008对文件和日志管理进行了优化,所以以下语句在SQL2005中可以运行但在SQL2008中已经被取消:(SQL2005) Backup Log DataBaseName with no_ ...
- √GMAP.NET 地图
深入理解最强桌面地图控件GMAP.NET ---[更新]百度地图 enjoyeclipse 2013-11-18 22:23 阅读:3897 评论:20 深入理解最强桌面地图控件GMAP.NE ...
- python学习之socket创建html服务器
#coding:utf-8 import socket def process_request(request): request.recv(1024)#读取接受的字节 request.send(&q ...
- ubuntu安装QQ目前最完善的方法!(亲测,成功)
wine qq 2012 for linux Ubuntu 64位兼容(12月21日末日版) 由 smile » 2011-04-07 9:08 +-------------------------- ...