Educational Codeforces Round 34 (Rated for Div. 2) A B C D
Educational Codeforces Round 34 (Rated for Div. 2)
A Hungry Student Problem
题目链接:
http://codeforces.com/contest/903/problem/A
思路:
直接模拟
代码:
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
scanf("%d",&n);
while(n--) {
int num,flag=0;
scanf("%d",&num);
for(int i=0;i<=num/3;++i) for(int j=0;j<=num/7;++j) if(3*i+7*j==num) flag=1;
if(flag) printf("YES\n");
else printf("NO\n");
}
return 0;
}
B The Modcrab
题目链接:
http://codeforces.com/contest/903/problem/B
思路:
模拟打怪兽的过程,需要注意的是,能够尽量打的情况坚决不舔包。就是说在一个回合中,怪兽能把你打死,但是你也能打死怪兽,这个时候先下手为强。其余情况下,保证自己活到下一回合。
代码:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e7+5;
ll d[maxn];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll h1,h2,a1,a2,c1,tot=0;
cin>>h1>>a1>>c1;
cin>>h2>>a2;
while(!(h2<=0)) {
if(h2-a1<=0) {
d[tot]=1;
h2=h2-a1;
} else if(h1-a2>0) {
d[tot]=1;
h2=h2-a1;
} else {
d[tot]=0;
h1=h1+c1;
}
tot=tot+1;
h1=h1-a2;
}
cout<<tot<<endl;
for(int i=0;i<tot;i=i+1) {
if(d[i]) {
cout<<"STRIKE"<<endl;
} else {
cout<<"HEAL"<<endl;
}
}
return 0;
}
C Boxes Packing
题目链接:
http://codeforces.com/contest/903/problem/C
思路:
找到某一个数的数量,且该数的数量是全部数里面最大的,就是答案。多此一举的离散化了一下。(¦3」∠)
代码:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn = 1e9+5;
ll data[5005],ans[5005],res[5005];
int main() {
ll n,maxnum=0;
scanf("%I64d",&n);
for(int i=0;i<n;++i) scanf("%I64d",&data[i]),ans[i]=data[i];
sort(data,data+n);
int tot=unique(data,data+n)-data;
for(int i=0;i<n;++i) {
ans[i]=lower_bound(data,data+tot,ans[i])-data;
res[ans[i]]++;
}
for(int i=0;i<tot;++i) maxnum=max(maxnum,res[i]);
printf("%I64d\n",maxnum);
return 0;
}
D Almost Difference
题目链接:
http://codeforces.com/contest/903/problem/D
思路:
爆了long long,所以使用long double。另外是用c++14提交的,c++11提交就是过不了,读入数据部分就会和本地不一样。
代码:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 200005;
ll a[maxn];
int n;
long double sum=0;
map<ll,int> mp;
int main() {
scanf("%d",&n);
for(int i=1;i<=n;++i) {
scanf("%I64d",&a[i]);
sum+=(long double)(i-1)*(long double)a[i];
sum-=(long double)(n-i)*(long double)a[i];
}
for(int i=1;i<=n;++i) {
mp[a[i]]++;
sum-=(long double)mp[a[i]-1];
sum+=(long double)mp[a[i]+1];
}
printf("%.0Lf\n",sum);
return 0;
}
Educational Codeforces Round 34 (Rated for Div. 2) A B C D的更多相关文章
- Educational Codeforces Round 34 (Rated for Div. 2) D - Almost Difference(高精度)
D. Almost Difference Let's denote a function You are given an array a consisting of n integers. You ...
- Educational Codeforces Round 34 (Rated for Div. 2) C. Boxes Packing
C. Boxes Packing time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- Educational Codeforces Round 34 (Rated for Div. 2)
A. Hungry Student Problem time limit per test 1 second memory limit per test 256 megabytes input sta ...
- Educational Codeforces Round 34 (Rated for Div. 2) B题【打怪模拟】
B. The Modcrab Vova is again playing some computer game, now an RPG. In the game Vova's character re ...
- Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块
Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块 [Problem Description] ...
- Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship
Problem Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...
- Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)
Problem Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...
- Educational Codeforces Round 43 (Rated for Div. 2)
Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...
- Educational Codeforces Round 35 (Rated for Div. 2)
Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...
随机推荐
- 入职第一天,装环境 .Ubuntu装jdk1.8,装idea 及tomcat
入职第一天,和之前公司的开发环境感觉天壤之别了,不过万变不离其宗,之前公司eclipse+widows.所以很少玩linux了.今天来就干了一件事.装环境 jdk安装. 下载地址:https://ww ...
- python-->二进制的用法
1.10进制转换为其他进制 方法一:函数 十进制转二进制:bin(10) --> '0b1010' tpye:是字符串类型 0b:表示2进制 十进制转八进制:oct(10) --> '0o ...
- 正睿OI集训游记
什么嘛....就是去被虐的... 反正就是难受就是了.各种神仙知识点,神仙题目,各式各样的仙人掌..... 但是还是学会了不少东西...... 应该是OI生涯最后一次集训了吧.... 这次的感言还是好 ...
- Apache服务部署静态网站
Web网络服务也叫WWW(World Wide Web),一般是指能够让用户通过浏览器访问到互联网中文档等资源的服务. 目前提供WEB网络服务的程序有Apache.Nginx或IIS等等,Web网站服 ...
- python经典面试算法题1.4:如何对链表进行重新排序
本题目摘自<Python程序员面试算法宝典>,我会每天做一道这本书上的题目,并分享出来,统一放在我博客内,收集在一个分类中. 1.4 对链表按照如下要求重新排序 [微软笔试题] 难度系数: ...
- zookeeper集群模式安装
服务器节点规划: 节点1:192.168.0.103 节点2:192.168.0.104 节点3:192.168.0.105 安装zookeeper,将zookeeper上传到三个服务器,保存在/ho ...
- 开启docker中的mongodb认证授权
前言: 开启MongoDB服务后,默认是没有权限验证的.直接通过IP加端口就可以远程访问数据库,并对数据库进行任意操作.下面介绍一下如何开启docker中MongoDB的权限认证. 安装完MongoD ...
- PHP 格式化公钥私钥(pem文件)
<?php header("Content-Type: text/html; charset=utf-8"); $filename = dirname(__FILE__).& ...
- C++中对封装的语法支持——this指针
this指针 1.this概念 (1) This指针就是用于成员函数区分调用对象. (2) This指针由编译器自动传递,无须手动传递,函数内部隐藏了this指针参数,本类类型的指针. (3) 编译器 ...
- 使用 Casbin 作为 ThinkPHP 的权限控制中间件
PHP-Casbin 是一个强大的.高效的开源访问控制框架,它支持基于各种访问控制模型的权限管理. Think-Casbin 是一个专为 ThinkPHP5.1 定制的 Casbin 的扩展包,使开发 ...