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 ...
随机推荐
- no module named firefly.master.master
因为没有安装firefly python setup.py install
- slot的含义
1) slot就是槽的意思,是一个资源单位,只有给task分配了一个slot之后,这个task才可以运行.slot分两种,map slot沪蓉reduce slot.另外,slot是一个逻辑概念,一个 ...
- OPEN资讯
http://www.open-open.com/news/view/1f55540 随着 Android 平台市场份额的持续猛增 , 越来越多的开发者开始投入 Android 应用程序的开发大潮.如 ...
- ELk 几篇好的文章
https://nxlog.co/docs/elasticsearch-kibana/using-nxlog-with-elasticsearch-and-kibana.html http://www ...
- Linux信号处理1
函数原型 NAME signal - ANSI C signal handling SYNOPSIS #include <signal.h> typedef void (*sighandl ...
- JS初学的一些易错的知识点
1. false ,0 , "" ,undefined , null 在Boolean 环境下当成 false: null 在数值环境下当成 0: undefined 在数值 ...
- js中几个正则表达式相关函数使用时g标志的作用
首先,javascript中涉及到正则表达式的函数总共有6个,可分为两种: 1.第一种是作为字符串对象的方法,即以 String.fun(); 形式调用,这里包括 split.search.match ...
- 【PSR规范专题(5)】PSR-4 改进后的自动加载规范
本文转自: https://github.com/PizzaLiu/PHP-FIG/blob/master/PSR-4-autoloader-cn.md 关键词 "必须"(&quo ...
- JLink and JTAG等接口简介
1.JTAG JTAG用的计算机的并口,JTAG也是一种国际标准测试协议(IEEE 1149.1兼容),主要用于芯片内部测试.现在多数的高级器件都支持JTAG协议,如DSP.FPGA器件等. 标准的J ...
- qt练习10 涂鸦板源代码
源代码下载: http://files.cnblogs.com/hnrainll/doodle.zip http://www.cnblogs.com/hnrainll/archive/2011/05/ ...