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 ...
随机推荐
- css 重新学习系列(2)
摘自: http://www.cnblogs.com/liuzhaoyang/articles/3289456.html Position定位:relative | absolute 定位一直是WEB ...
- NSFileManager创建文件夹
NSFileManager*fileManager = [[NSFileManager alloc] init]; NSString *pathDocuments = [NSSearchPathFor ...
- DEAMONTOOLS: installation
installing daemontools .. adding -I /usr/include/errno.h to last first line of conf-cc mkdir -p /pac ...
- 【Python初学】深copy&浅copy
在python中,对象赋值实际上是对象的引用.当创建一个对象,然后把它赋给另一个变量的时候,python并没有拷贝这个对象,而只是拷贝了这个对象的引用. 1. copy.copy 浅拷贝 只拷贝父对象 ...
- JS-DOM操作应用高级(二)
搜索 字符串比较.忽略大小写----大小写转换.模糊搜索----search的使用.split.高亮显示及筛选 toLowerCase() 方法用于把字符串转换为小写 str.search('') ...
- 天棋哥哥大战AlphaGo
天棋哥哥大战AlphaGo Time Limit: 1 Sec Memory Limit: 128 MB Submit: 20 Solved: 9 [Submit][Status][Web Boa ...
- HDU 5240 Exam
The 2015 ACM-ICPC China Shanghai Metropolitan Programming Contest 2015ACM-ICPC上海大都会赛 签到题 #include< ...
- 2017 ZSTU寒假排位赛 #1
题目链接:https://vjudge.net/contest/147102#overview. A题:给出一堆的点,要找出两条垂直的直线,一条与x轴呈45度.-->使得所有的点到任意一条直线的 ...
- 如何修改apache的默认web端口
在apache的安装文件夹里搜索 httpd.conf 文件,用记事本打开,搜索 Listen 80 ,把80(默认端口)改为你想用的端口,保存,重新启动apache服务即可!
- redis五种数据类型的使用
redis五种数据类型的使用 redis五种数据类型的使用 (摘自:http://tech.it168.com/a2011/0818/1234/000001234478_all.shtml ) 1.S ...