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 ...
随机推荐
- 关于iOS9中配置App Transport Security(应用程序传输安全协议)
在 在info.plist中,进行上面的配置就行了,注意的是,那个网址,你需要访问什么网址,就填写什么网址就行了. NSTemporaryExceptionAllowsInsecureHTTPLoad ...
- ios开发入门篇(四):UIWebView结合UISearchBar的简单用法
UIWebView是ios开发中比较常用的一个控件.我们可以用它来浏览网页.打开文档等,今天笔者在这里简单介绍下UIWebView和UISearchBar结合起来的用法,做一个简单的类浏览器. 一: ...
- UIDynamic 基础认识
UIDynamic 是从iOS 7开始引入的一种新技术,属于UIKit框架,可以模拟现实生活中的物理现象,如:碰撞.抖动.摆动等 动力效果:有一个效果器,叫做“动力效果器”里面面可以添加“动力效果” ...
- ASP.NET MVC 路由进阶(之二)--自定义路由约束
3.自定义路由约束 什么叫自定义路由约束呢?假如路由格式为archive/{year}/{month}/{day},其中year,month,day是有约束条件的,必须是数字,而且有一定范围. 这时候 ...
- 字符串转与ASCII码之间的互换
1.字符串转换成ASCII码 public static String stringToAscii(String value) { StringBuffer sbu = new StringBuffe ...
- 在O(1)时间删除链表结点
题目:给定单向链表的头指针和一个结点指针,定义一个函数在O(1)时间删除该结点. 链表结点与函数的定义如下: struct ListNode { int m_nValue; ListNode* m_p ...
- 从一个乘法来分析C语言
昨天碰到一个很奇怪的问题,首先来看这段代码: #include<stdio.h> int main(int argc,char *argv[]) { ; ; long long res1 ...
- 代码动态创建checkbox
根据数据库的内容动态创建Checkbox控件并显示在Panel上 dataset ds=new dataset(); CheckBox[ ] cb=new CheckBox[ds.tables[0]. ...
- 思道OA PK 通达OA 同场竞技 谁与争锋
技术架构 思道OA 通达OA 开发语言 微软ASP.NET 4.0 PHP开源脚本语言 64位平台 64位 32位 数据库 SQL Server大数据库 MySQL开源数据库 官网下载 下载地址 下载 ...
- 【原创】一起学C++ 之指针的--/++ ---------C++ primer plus(第6版)
讲*和++同时用于指针时提出了这样的问题:将什么解除引用,将什么递增. ]={21.1, 32.8, 23.4, 45.2, 37.4 }; double *pt=arr; //pt指针指向arr[0 ...