Codeforces Round #355 (Div. 2)
A
弯腰
#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
#define clc(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
const int N=;
#define LL long long
// inline int r(){
// int x=0,f=1;char ch=getchar();
// while(ch>'9'||ch<'0'){if(ch=='-') f=-1;ch=getchar();}
// while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
// return x*f;
// } int main(){
int n,m;
int ans=;
scanf("%d%d",&n,&m);
for(int i=;i<n;i++){
int x;
cin>>x;
if(x<=m)
ans+=;
else
ans+=;
}
cout<<ans<<endl;
return ;
}
B
处理器一秒能处理k个东西,缓冲区最多不能超过h个,问几秒处理完
模拟,注意h很大,k很小的情况!!所以必须用除法避免超时
#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
#define clc(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
const int N=;
#define LL long long
void fre(){freopen("in.txt","r",stdin); }
// inline int r(){
// int x=0,f=1;char ch=getchar();
// while(ch>'9'||ch<'0'){if(ch=='-') f=-1;ch=getchar();}
// while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
// return x*f;
// }
int a[]; int main(){
// fre();
int n,h,k;
cin>>n>>h>>k;
for(int i=;i<=n;i++){
scanf("%d",&a[i]);
}
LL sum=;
LL ans=;
for(int i=;i<=n;i++){
sum+=a[i];
while(sum+a[i+]<=h){
sum+=a[i+];
i++;
if(i>n)
break;
}
// cout<<i<<" "<<sum<<endl;
while(){
int tem=sum;
sum%=k;
ans+=tem/k;
if(sum<=)
{
sum=;
break;
}
if(i<n){
if(sum+a[i+]<=h)
break;
}
if(sum<k&&sum>){
sum=;
ans++;
// cout<<sum<<" "<<ans<<endl;
break;
}
}
// cout<<i<<" "<<sum<<endl;
}
cout<<ans<<endl;
return ;
}
C
统计每个字符对应的数字有几个0,答案就是pow(3,n)。二进制是六位
#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
#define clc(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
const int N=;
const int MOD = 1e9+;
#define LL long long
void fre(){freopen("in.txt","r",stdin); }
// inline int r(){
// int x=0,f=1;char ch=getchar();
// while(ch>'9'||ch<'0'){if(ch=='-') f=-1;ch=getchar();}
// while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
// return x*f;
// }
LL pow_m(LL a,LL b)
{
LL ans = ;
a %= MOD;
while(b)
{
if(b & )
{
ans = ans * a % MOD;
b--;
}
b >>= ;
a = a * a % MOD;
}
return ans;
} int fun(int x){
int num=;
int cnt=;
while(cnt){
if((x&)==)
num++;
x>>=;
cnt--;
}
return num;
}
string s;
bool vis[];
int main(){
// freopen("in.txt","r",stdin);
getline(cin,s);
LL num=;
LL ans=;
clc(vis,false);
for(int i=;i<s.length();i++){
int x;
if(s[i]>=''&&s[i]<=''){
x=s[i]-'';
num+=fun(x);
}
else if(s[i]>='A'&&s[i]<='Z'){
x=s[i]-'A'+;
num+=fun(x);
}
else if(s[i]>='a'&&s[i]<='z'){
x=s[i]-'a'+;
num+=fun(x);
}
else if(s[i]=='-'){
num+=fun();
}
else{
num+=fun();
}
}
// cout<<num<<endl;
ans=pow_m(,num);
printf("%I64d\n",ans);
return ;
}
Codeforces Round #355 (Div. 2)的更多相关文章
- 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 ...
- Codeforces Round #355 (Div. 2) B. Vanya and Food Processor 水题
B. Vanya and Food Processor 题目连接: http://www.codeforces.com/contest/677/problem/B Description Vanya ...
- Codeforces Round #355 (Div. 2) A. Vanya and Fence 水题
A. Vanya and Fence 题目连接: http://www.codeforces.com/contest/677/problem/A Description Vanya and his f ...
随机推荐
- ExtJS4.2学习(四)Grid表格中文排序问题(转)
鸣谢:http://www.shuyangyang.com.cn/jishuliangongfang/qianduanjishu/2013-11-07/173.html --------------- ...
- [转载]C#缓存absoluteExpiration、slidingExpiration两个参数的疑惑
看了很多资料终于搞明白cache中absoluteExpiration,slidingExpiration这两个参数的含义. absoluteExpiration:用于设置绝对过期时间,它表示只要时间 ...
- Ubuntu 14.04 启用休眠
Ubuntu 14.04 启用休眠 Ubuntu 14.04 默认不启用关机菜单中的休眠选项.前提是要有swap分区(网上查询,未验证是否一定需要.PS:swap要不小于物理内存)不过首先最好还是确认 ...
- Slider 滑动条效果
转载自:http://www.cnblogs.com/cloudgamer/archive/2008/12/24/Slider.html 这个滑动条(拖动条)效果,一开始是参考了BlueDestiny ...
- 时序列数据库武斗大会之 TSDB 名录 Part 1
[编者按] 刘斌,OneAPM后端研发工程师,拥有10多年编程经验,参与过大型金融.通信以及Android手机操作系的开发,熟悉Linux及后台开发技术.曾参与翻译过<第一本Docker书> ...
- 深入浅出ShellExecute
Q: 如何打开一个应用程序? ShellExecute(this->m_hWnd,"open","calc.exe",""," ...
- Android 国际化文字
本例演示中英文切换 在resource文件夹添加values-zh,这个文件夹对应中文环境的values文件夹,然后添加strings.xml: <?xml version="1.0& ...
- BZOJ 3997 TJOI2015 组合数学
分析一下样例就可以知道,求的实际上是从左下角到右上角的最长路 因为对于任意不在这个最长路的上的点,都可以通过经过最长路上的点的路径将这个点的价值减光 (可以用反证法证明) 之后就是一个非常NOIP的D ...
- java中List集合及其遍历详解
1. 首先List<E>集合继承与Collection<E>,是一个接口. ① Collection (集合框架是JDK1.2版本出现的) ② list:是有序的,元素可 ...
- C#基础精华03(常用类库StringBuilder,List<T>泛型集合,Dictionary<K , V> 键值对集合,装箱拆箱)
常用类库StringBuilder StringBuilder高效的字符串操作 当大量进行字符串操作的时候,比如,很多次的字符串的拼接操作. String 对象是不可变的. 每次使用 System. ...