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 ...
随机推荐
- PhoneGap 3.0 官方 安装 方法
为使用最新版本PhoneGap ,决定使用官方提供的方法安装一次. 官方提供方法有些地方没有提到,因此这里记录完整的安装过程: 0.下载java sdk 1.6以上版本 1.下载Android Dev ...
- PAT-乙级-1017. A除以B (20)
1017. A除以B (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 本题要求计算A/B,其中A是不超过 ...
- hdu 1176
简单DP 类似于在一个矩形中求最长路径 /************************************************************************* > ...
- uva 10739
dp 只有三个操作 当str[i] != str[j] 时 dp(i, j) = min(dp(i+1, j), dp(i+1, j-1), dp(i, j-1)) #include <ios ...
- Flask, Tornado, GEvent, 以及它们的结合的性能比较
Flask, Tornado, GEvent, 以及它们的结合的性能比较 英文: http://blog.wensheng.com/2011/10/performance-of-flask-torna ...
- 修改netbeans模版头部的说明
以新建一个php类文件为例: 有两个地方需要修改, 1,工具->模版->默认许可证->在编辑器中打开 2,工具->模版->选择php类->在编辑器中打开 即可进行修 ...
- Win7 默认hosts文件
# Copyright (c) 1993-2009 Microsoft Corp. # # This is a sample HOSTS file used by Microsoft TCP/IP f ...
- Eclipse字体修改设置
修改字体 Window -> Preferences -> General -> Appearences -> Colors and Fonts 选择java选项,看到Java ...
- LinkedList源代码深入剖析
第1部分 LinkedList介绍LinkedList简介 public class LinkedList<E> extends AbstractSequentialList<E&g ...
- 120. Triangle
题目: Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjace ...