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& ...
随机推荐
- 有关logistic(sigmoid)函数回归
在神经网络中,经常用到sigmoid函数,y = 1 / (1+e-x) 作为下一级神经元的激活函数,x也就是WX(下文,W以θ符号代替)矩阵计算结果. 这个函数通常用在进行分类,通常分为1或0的逻辑 ...
- 命令行代理神器 proxychains
因为某些原因,我们需要在命令行下载一些国外的资源,这个时候如果使用 wget,curl,或者 aria2c 的时候,往往又没有速度.这个时候我们需要使用代理来进行加速. 我本地搭的有 ss,但 ss ...
- numpy.array 合并和分割
# 导包 import numpy as np numpy.array 的合并 .concatenate() 一维数组 x = np.array([1, 2, 3]) # array([1, 2, 3 ...
- css3 preserve-3d 的理解 注意IOS上的兼容
css3 preserve-3d 的理解 <pre><!DOCTYPE html><html lang="en"> <head> & ...
- 支付宝小程序和微信小程序的区别(部分)
支付宝小程序和微信小程序之间的互相转换 1.首先是文件名 微信小程序 wxss ------ 支付宝小程序 acss 微信小程序 wxml ------ 支付宝小程序 axml 2.调用方法前缀 微信 ...
- JMeter的安装部署——Linux系统
1.配置Java环境 在官网https://www.oracle.com/technetwork/java/javase/downloads/jdk10-downloads-4416644.html下 ...
- Linux从git上下东西
git clone 网址 git clone https://github.com/walkor/Workerman
- C++中对C的扩展学习新增语法——For循环以及AUTO类型
For循环以及AUTO类型 For代码实现: AUTO类型: 1.auto自动类型推导,省事. 2.auto主要在模板中用的多,模板的类型比较长,使用auto可以简化代码. 3.不要轻易使用,我们在编 ...
- Kafka needs no Keeper(关于KIP-500的讨论)
写在前面的 最近看了Kafka Summit上的这个分享,觉得名字很霸气,标题直接沿用了.这个分享源于社区的KIP-500,大体的意思今后Apache Kafka不再需要ZooKeeper.整个分享大 ...
- 使用 layUI做一些简单的表单验证
使用 layUI做一些简单的表单验证 <form method="post" class="layui-form" > <input name ...