大小号刷题,大号,被查重,悲剧,最后小号过了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的更多相关文章

  1. 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 ...

  2. Codeforces Round #355 (Div. 2)-C

    C. Vanya and Label 题目链接:http://codeforces.com/contest/677/problem/C While walking down the street Va ...

  3. Codeforces Round #355 (Div. 2)-B

    B. Vanya and Food Processor 题目链接:http://codeforces.com/contest/677/problem/B Vanya smashes potato in ...

  4. Codeforces Round #355 (Div. 2)-A

    A. Vanya and Fence 题目连接:http://codeforces.com/contest/677/problem/A Vanya and his friends are walkin ...

  5. Codeforces Round #355 (Div. 2) D. Vanya and Treasure dp+分块

    题目链接: http://codeforces.com/contest/677/problem/D 题意: 让你求最短的从start->...->1->...->2->. ...

  6. E. Vanya and Balloons Codeforces Round #355 (Div. 2)

    http://codeforces.com/contest/677/problem/E 题意:有n*n矩形,每个格子有一个值(0.1.2.3),你可以在矩形里画一个十字(‘+’形或‘x’形),十字的四 ...

  7. D. Vanya and Treasure Codeforces Round #355 (Div. 2)

    http://codeforces.com/contest/677/problem/D 建颗新树,节点元素包含r.c.dis,第i层包含拥有编号为i的钥匙的所有节点.用i-1层更新i层,逐层更新到底层 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. Learning Java characteristics (Java in a Nutshell 6th)

    Java characteristics: Java .class files are machine-independent, including the endianness. Java .cla ...

  2. Struts2值栈详解

    1. 关于值栈: 1). helloWorld 时, ${productName} 读取 productName 值, 实际上该属性并不在 request 等域对象中, 而是从值栈中获取的.  2). ...

  3. 关于在jsp中的表达式

    列子: <%List<F_dd_tourist_info_markup> tourists = (List<F_dd_tourist_info_markup>) requ ...

  4. shell 分词

    ######################################################################### # File Name: hello.sh # Au ...

  5. 记一次坑die(误)的题目--HDU2553--(DFS)

    ,N皇后问题   Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Subm ...

  6. angularjs中动态为audio绑定src

    今天在angularjs中用audio的时候碰到的这些问题,查阅http://www.cnblogs.com/rachelanlan/p/3598070.html获得解决,感谢! <div cl ...

  7. android Service Activity三种交互方式(付源码)(转)

    android Service Activity三种交互方式(付源码) Android应用服务器OSBeanthread  android Service Binder交互通信实例 最下边有源代码: ...

  8. (转)StringTokenizer类的使用

    StringTokenizer是一个用来分隔String的应用类,相当于VB的split函数.1.构造函数public StringTokenizer(String str)public String ...

  9. Hadoop远程调用机制

  10. WebDriver(Selenium2) 处理可能存在的JS弹出框

    http://uniquepig.iteye.com/blog/1703103 在自动化测试过程中,有些情况下我们会遇到一些潜在的Javascript弹出框.(即某些条件下才会出现,不是固定出现),然 ...