ZeptoLab Code Rush 2015
A
题意:给出一串由.*组成的字符串,如果有等间距的五个及五个以上的*存在,则输出yes
直接枚举就可以了
看题一定要仔细啊,做的时候看成必须有五个等间距的".*"才可以跳跃= =
然后就这样写居然过了预测= =后来果然被hack了
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cmath>
#include<stack>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#define mod=1e9+7;
using namespace std; typedef long long LL;
const int INF = 0x7fffffff; int main(){
char s[];
int n,i,j;
scanf("%d",&n);
scanf("%s",s);
for(i=;i<n;i++){
for(j=;j<n;j++){
if(s[i]=='*'&&s[i+j]=='*'&&s[i+*j]=='*'&&s[i+*j]=='*'&&s[i+*j]=='*'){
printf("yes\n");
return ;
}
}
}
printf("no\n");
return ;
}
B
题意:如图所示,需要从根节点到最下面一层得叶子节点的灯的数量相等,问最少需要添加多少盏灯
因为需要每一条支路的灯的数量相等,所以从最下面一层开始处理((因为到分叉之前的灯都是共用的),不同的话加灯,相同的话继续往上一层处理
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cmath>
#include<stack>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#define mod=1e9+7;
using namespace std; typedef long long LL;
const int INF = 0x7fffffff;
int a[]; int mi(int x){
int ans=;
for(int i=;i<=x;i++) ans*=;
return ans;
} int main(){
int n,i,j,ans,k;
cin>>n;
int idx=mi(n+)-;
for(i=;i<=idx;i++) scanf("%d",&a[i]); ans=;
for(i=n;i>=;i--){
for(j=mi(i);j<=mi(i+)-;j=j+){
if(a[j]!=a[j+]) {
int tmp=a[j]-a[j+];
if(tmp<) tmp=-tmp;
ans+=tmp;
// printf("ans=%d\n",ans);
} int cc=max(a[j],a[j+]);
a[j/]+=cc;
}
} printf("%d\n",ans);
return ;
}
C
题意:给出容量c,蓝色的糖和红色的糖分别的快乐值v1,v2,分别的重量w1,w2 求最大的快乐值
做的时候想成背包,想到这么大的容量数组怎么开得下= =
后来暴力,枚举买蓝色糖的数目从1到100000000,超时
后来搜了题解= = 发下枚举到100000就可以了,另外要从0开始枚举,因为可能不吃这种糖果
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cmath>
#include<stack>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#define mod=1e9+7;
using namespace std; typedef long long LL;
const int INF = 0x7fffffff; int main(){
LL c,v1,v2,w1,w2,i;
cin>>c>>v1>>v2>>w1>>w2;
LL ans=-;
for(i=;i<=;i++){
LL y=(c-i*w1)/w2;
LL tmp=v2*y+i*v1;
if((c-i*w1)<=) break;
ans=max(ans,tmp);
} for( i=;i<=;i++){
LL y=(c-i*w2)/w1;
LL tmp=v2*i+v1*y;
if((c-i*w2)<=) break;
ans=max(ans,tmp);
}
if(ans<) printf("0\n");
else printf("%I64d\n",ans);
return ;
}
这个周六先做bc被虐成狗= =做cf被虐成狗---555555
加油啊---go--go--go--go--go--go
ZeptoLab Code Rush 2015的更多相关文章
- ZeptoLab Code Rush 2015 A. King of Thieves 暴力
A. King of Thieves Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/526/pr ...
- CodeForces ZeptoLab Code Rush 2015
拖了好久的题解,想想还是补一下吧. A. King of Thieves 直接枚举起点和5个点之间的间距,进行判断即可. #include <bits/stdc++.h> using na ...
- Codeforces - ZeptoLab Code Rush 2015 - D. Om Nom and Necklace:字符串
D. Om Nom and Necklace time limit per test 1 second memory limit per test 256 megabytes input standa ...
- ZeptoLab Code Rush 2015 C. Om Nom and Candies 暴力
C. Om Nom and Candies Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/526 ...
- ZeptoLab Code Rush 2015 B. Om Nom and Dark Park DFS
B. Om Nom and Dark Park Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...
- Codeforces ZeptoLab Code Rush 2015 D.Om Nom and Necklace(kmp)
题目描述: 有一天,欧姆诺姆发现了一串长度为n的宝石串,上面有五颜六色的宝石.他决定摘取前面若干个宝石来做成一个漂亮的项链. 他对漂亮的项链是这样定义的,现在有一条项链S,当S=A+B+A+B+A+. ...
- ZeptoLab Code Rush 2015 C. Om Nom and Candies [ 数学 ]
传送门 C. Om Nom and Candies time limit per test 1 second memory limit per test 256 megabytes input sta ...
- ZeptoLab Code Rush 2015 B. Om Nom and Dark Park
Om Nom is the main character of a game "Cut the Rope". He is a bright little monster who l ...
- Code Rush插件
code rush 是微软推出的一款VS2008上的插件.他有强大的文件和代码导航功能,易于访问的重构和代码创建功能.一组编辑器.选择.剪贴板工具等. 教程链接 http://www.devexpre ...
随机推荐
- python模拟shell
import fileinput import readline raw_input(xxx) exec filepinput.input
- 13test02:信用卡校验
/*#include<iostream> using namespace std; void input(); int counter=0,jishu_sum=0,oushu_sum=0, ...
- javascript实现KMP算法(没啥实用价值,只供学习)
简单粗暴上代码 KMP的原理我就不讲了,想转过弯儿来不容易,建议大家先学会了怎么推导出next数组规律,然后准备两张纸,大纸上写上一行你要匹配的目标字符串,并分别写出位置编号,小纸上写上一行,也写上位 ...
- Delphi的Socket编程步骤
ClientSocket 和ServerSocket几个重要的属性: 1.client和server都有port属性,需要一致才能互相通信 2.client有Address属性,使用时填写对方 ...
- HDU4784 Dinner Coming Soon(dp)
当时区域赛的一道题.题意大概是这样的,有一个1~N的图,然后你要从1->N,其中每经过一条边需要消耗你的时间和金钱,每到一个地方可以选择什么都不做,或者买一包盐,卖一包盐,身上不能同时有超过B包 ...
- Java集合框架(三)
Map Map集合:该集合存储键值对,一对一对的往里存,而且要保证键的唯一性. Map |------HashTable:底层是哈希表数据结构,不可以存入null键null值.该集合是线程同步的.J ...
- Tomcat打印运行时日志(控制台),访问日志,启动日志
1.sh catlina.sh run以控制台形式输出 2.sever.xml.配置acesslog,设置访问日志输出 Tomcat的访问日志是靠org.apache.catalina.valves. ...
- 天使投资、VC 以及 PE 的区别是什么?
如果满足于“阶段不同”这个简单的回答,那你可能错过了一个思考资本与企业发展之间关系的机会. 首先要交待一下,在大众语境中,angel/VC/PE三者都可认为是VC,也就是人们常说的风险投资,在国内官方 ...
- # 图解TCP/IP读书笔记(五)
第五章.IP协议相关技术 IP旨在让最终目标主机收到数据包,但是在这一过程中仅仅有IP是无法实现通信的,因此还有需要作为为IP的辅助的各种协议支持. 协议 作用 特点 DNS(Domain Name ...
- JVM垃圾回收机制总结(3) :按代垃圾收集器
为什么要分代 分代的垃圾回收策略,是基于这样一个事实:不同的对象的生命周期是不一样的 . 因此,不同生命周期的对象可以采取不同的收集方式,以便提高回收效率. 在Java程序运行的过程中,会产生大量的对 ...