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 ...
随机推荐
- zend frameword 基本语法
#resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"#resources.frontCo ...
- 快学Scala-第一章 基础
知识点: Scala程序并不是一个解释器,实际发生的是,你输入的内容被快速的编译成字节码,然后这段字节码交由Java虚拟机执行. 以val定义的值是一个常量,以var定义的值是一个变量,声明值或变量但 ...
- 留言本,keyCode
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...
- hdu 1560 DNA sequence(迭代加深搜索)
DNA sequence Time Limit : 15000/5000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Total ...
- Android开发10.2:UI组件AutoCompleteTextView(自动完成文本框)
概述 AutoCompleteTextVeiw(自动完成文本框)从 EditText派生而出 PS :EditText用法介绍 当用户输入一定字符后,自动完成自动完成文本框会显示 ...
- mplayer最全的命令
前段时间做过qt内嵌mplayer的一个小程序,感觉mplayer还行不过不支持打开图片感觉有点无力.话不多说上代码: QString path="d:/1.mkv"; QWidg ...
- CodeForces 383D Antimatter
线性DP. dp[i][j]表示以第i个数字为结尾的,字串和为j的有几种. #include<cstdio> #include<cstring> #include<cma ...
- PAT (Advanced Level) 1105. Spiral Matrix (25)
简单模拟. #include<cstdio> #include<cstring> #include<cmath> #include<map> #incl ...
- springMVC的拦截器工作流程
首先,springmvc的拦截器配置在这就不多说了.主要讲一下拦截器的三个方法的执行顺序. preHandle方法一定是最先执行的方法,如果它返回为false下面的方法均不执行. postHandle ...
- setAttribute的兼容性
class和className兼容方法: object.setAttribute("class","content") 在IE8.Chrome.火狐.Opera ...