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 ...
随机推荐
- iOS16进制设置颜色
UIColor+Hex.h // // UIColor+Hex.h // 16进制颜色类别 // // Created by apple on 15-4-3. // Copyright (c) 201 ...
- 深入浅出ES6(十一):生成器 Generators,续篇
作者 Jason Orendorff github主页 https://github.com/jorendorff 欢迎回到深入浅出ES6专栏,望你在ES6探索之旅中收获知识与快乐!程序员们在工作 ...
- poj 3613(经过N条边的最短路)
题目链接:http://poj.org/problem?id=3613 思路:我们知道如果矩阵A表示经过1条边的方案数,那么A^N矩阵就代表这经过N条边的方案数,而本题中要求经过N条边的最短距离,于是 ...
- maven编译时候报"编码 GBK 的不可映射字符"
决这个问题的思路: 在maven的编译插件中声明正确的字符集编码编码——编译使用的字符集编码与代码文件使用的字符集编码一致!! 安装系统之后,一般中文系统默认字符集是GBK.我们安装的软件一般都继承使 ...
- NOIP模拟赛 by hzwer
2015年10月04日NOIP模拟赛 by hzwer (这是小奇=> 小奇挖矿2(mining) [题目背景] 小奇飞船的钻头开启了无限耐久+精准采集模式!这次它要将原矿运到泛光之源的矿 ...
- 【PSR规范专题(2)】PSR-1 基本代码规范
转载自: https://github.com/PizzaLiu/PHP-FIG/blob/master/PSR-1-basic-coding-standard-cn.md 基本代码规范 本篇规范制定 ...
- 网络安装之Redhat衍生版
GNU/Linux开源,这个意义实在是非常的广泛,目前在distrowatch上表现活跃的300个发行版代表了GNU/Linux的主流,然而细心的Linux爱好者会发现CentOS-based dis ...
- 一个国外网盘pCloud——支持离线下载
给大家分享一个国外网盘<支持离线下载> https://my.pcloud.com/#page=register&invite=HiegZ8aBrt7
- C++:delete和delete[]释放内存的区别
C++告诉我们在回收用 new 分配的单个对象的内存空间的时候用 delete,回收用 new[] 分配的一组对象的内存空间的时候用 delete[]. 关于 new[] 和 delete[], ...
- Android消息机制之实现两个不同线程之间相互传递数据相互调用
目的:实现两个不同线程之间相互传递数据相互调用方法. 线程一中定义mainHandler 并定义一个方法mainDecode 线程二中定义twoHandler 并定义一个方法twoEncode 实现当 ...