Codeforces#355
大小号刷题,大号,被查重,悲剧,最后小号过了3题
A题:
分析:大于h的+2,小于等于h的+1
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
const int maxn=;
int a[maxn];
int n,h;
int main()
{
while(cin>>n>>h)
{
long long sum=;
for(int i=;i<n;i++){
int x;
scanf("%d",&x);
if(x>h)
sum+=;
else
sum+=;
}
cout<<sum<<endl;
}
return ;
}
B题:
题意:有n个长度分别为a1,a2.....an的木棒,每次可以削掉长度为k的,放入机器的最大长度不能大于h,一根接着一根地放入,问怎么才能用最少的次数
分析:看清题意发现是水题,一根接着一根放入,则我们判断一下上一根剩余的加上下一根的长度是否大于h,若大于,则只把剩余部分放入机器,否则把剩余部分和下一根一起放入机器
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
const int maxn=;
int a[maxn];
int k,n,h;
int main()
{
while(cin>>n>>h>>k)
{
memset(a,,sizeof(a));
for(int i=;i<n;i++)
scanf("%d",&a[i]);
int t,f;
long long cnt=;
for(int i=;i<n;i++){
t=a[i]/k; //需要几刀
f=a[i]%k; //切完之后当前这段还剩多少
cnt+=t;
if(a[i+]+f>h){ //不能切分
cnt++;
}else{ //可以切分
a[i+]+=f;
}
}
if(f) cnt++;
cout<<cnt<<endl;
}
return ;
}
C题:
题意:一个字符串里面的字符分别代表不同的数,字符串的每个数是由两个不同的数按位&得到的,问这样的组合最多有多少个
分析:若是0,则有0&0,1&0,0&1,3种,若是1只有1&1这1种,因此就是统计每个数的二进制有多少个0即可
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
const int mod=;
const int maxn=;
char str[maxn];
long long num[maxn];
long long solve(char s ){
long long x;
if(s>=''&&s<='')
x=s-'';
else if(s>='A'&&s<='Z')
x=s-'A'+;
else if(s>='a'&&s<='z')
x=s-'a'+;
else if(s=='-')
x=;
else
x=;
return x;
}
int main()
{ scanf("%s",str);
int n=strlen(str);
long long ans=;
for(int i=;i<n;i++){
long long x=solve(str[i]);
for(int j=;j<;j++){
if((x&(<<j))==)
ans=ans*%mod;
}
}
cout<<ans<<endl;
return ;
}
Codeforces#355的更多相关文章
- codeforces 355 div2 C. Vanya and Label 水题
C. Vanya and Label time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces Round #355 (Div. 2)-C
C. Vanya and Label 题目链接:http://codeforces.com/contest/677/problem/C While walking down the street Va ...
- Codeforces Round #355 (Div. 2)-B
B. Vanya and Food Processor 题目链接:http://codeforces.com/contest/677/problem/B Vanya smashes potato in ...
- Codeforces Round #355 (Div. 2)-A
A. Vanya and Fence 题目连接:http://codeforces.com/contest/677/problem/A Vanya and his friends are walkin ...
- Codeforces Round #355 (Div. 2) D. Vanya and Treasure dp+分块
题目链接: http://codeforces.com/contest/677/problem/D 题意: 让你求最短的从start->...->1->...->2->. ...
- E. Vanya and Balloons Codeforces Round #355 (Div. 2)
http://codeforces.com/contest/677/problem/E 题意:有n*n矩形,每个格子有一个值(0.1.2.3),你可以在矩形里画一个十字(‘+’形或‘x’形),十字的四 ...
- D. Vanya and Treasure Codeforces Round #355 (Div. 2)
http://codeforces.com/contest/677/problem/D 建颗新树,节点元素包含r.c.dis,第i层包含拥有编号为i的钥匙的所有节点.用i-1层更新i层,逐层更新到底层 ...
- Codeforces Round #355 (Div. 2) D. Vanya and Treasure 分治暴力
D. Vanya and Treasure 题目连接: http://www.codeforces.com/contest/677/problem/D Description Vanya is in ...
- Codeforces Round #355 (Div. 2) C. Vanya and Label 水题
C. Vanya and Label 题目连接: http://www.codeforces.com/contest/677/problem/C Description While walking d ...
随机推荐
- NSFileManager创建文件夹
NSFileManager*fileManager = [[NSFileManager alloc] init]; NSString *pathDocuments = [NSSearchPathFor ...
- 用PHP与XML进行网站编程
一.小序 HTML简单易学又通用,一般的PHP程序就是嵌入在HTML语言之中实现的.但是随着WEB越来越广泛的应用,HTML的弱点也越来越明显了.XML的出现,弥补了这些不足,它提供了一个能够处理互联 ...
- Cloudsim 3.0在myclipse下的安装过程
(1)下载cloudsim 3.0: http://code.google.com/p/cloudsim/downloads/list (2)下载flanaga.jar包 下载地址:http://w ...
- 转:Loadrunner学习知多少--脚本录制下载操作
在很多时候我们可能需要对系统进行这样的脚本开发,模拟用户点击一个下载链接,然后弹出下载框,选择保存,用来测试在大量用户下载时服务器的性能.但是现在大家对于这种脚本的处理方式往往是通过关联和C 语言的文 ...
- VC与ADO数据库操作
VC与ADO数据库操作 学研部的同志们,大家好! 想开一次学习会,实习时间冲突了,只好把文档发给大家看了.重点推荐李振龙的BMP读图教程! 尤其是大三GIS班的同志,注意了,可能实习用得上的! 一.A ...
- HBase集群安装
1.HBase的机群搭建过程(在原来的hadoop0上的HBase伪分布基础上进行搭建)1.1 集群结构,主节点(hmaster)是hadoop0,从节点(region server)是hadoop1 ...
- Linux 安装 Redis 服务
下载地址 http://download.redis.io/releases/redis-3.2.0.tar.gz 官网下载地址 http://redis.io/download 1.下载安装包 cd ...
- 区间DP 入门
首先我们先需要知道区间是如何用dp来做的,让我们来看一下模板. ; i <= n; i++){//枚举区间里面的个数 ; j <= 能枚举到得最大的pos; j++){ ;//表示在目前能 ...
- 用memcached的时候找key找不到,写了个命令来找找
for i in $(seq 30); do echo "stats cachedump $i 0" | nc 192.168.88.150 11211 | grep groupS ...
- zf-安徽桐城关于(资源中心-数据录入)上传文件后没有进行处理Excel文件的原因
上传的文件 是会自动复制到另外一个路径的 如果没有进行处理 那么表示那个路径并没有那个文件 这样就会卡死 导致之后的文件都不会进行处理(后台有个变量是从数据库里获得文件路径的),所以需要去数据库 执行 ...