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& ...
随机推荐
- MIT线性代数:10.4个基本子空间
- python 爬取网页简单数据---以及详细解释用法
一.准备工作(找到所需网站,获取请求头,并用到请求头) 找到所需爬取的网站(这里举拉勾网的一些静态数据的获取)----------- https://www.lagou.com/zhaopin/Pyt ...
- 考试T1护花
传送门 这题的提议似乎有什么问题,只要约翰选好了要抓那头牛,他就不会吃草了,站在原地傻等? 这题就是贪心,但在用cmp中比较单位时间吃草数量时,要用double型,不然可能会有点一样... 还有就是主 ...
- python之变量名
在python中,变量不需要提前声明,创建时直接对其赋值即可,变量类型由赋给变量的值决定.值得注意的是,一旦创建了一个变量,就需要给该变量赋值. 变量名应严格遵守以下规则: 1.变量名只能包含:字母/ ...
- MySQL系列:Windows 下 MySQL 8.X 的安装
之前一直使用的是MySQL5.7,但由于MySQL增加了一些新特性,所以选择了更新. 下载MySQL 进入MySQL官网下载地址,选择Windows (x86, 64-bit), ZIP Archiv ...
- 安装&卸载Windows服务
使用.NET Framework的工具InstallUtil.exe. 安装服务 C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.e ...
- nuxt遇到的问题(一)window 或 document is not defined
因为用了VUE做的官网,既然是官网了避免不了SEO的问题了(该死当初就不应该选择用vue) 很自然就是选择了使用nuxt.js来做ssr预渲染了. 因为网站不是响应式的,PC / 移动端要进行对应跳转 ...
- 爬虫多线程模板,xpath,etree
class QuiShi: def __init__(self): self.temp_url = "http://www.lovehhy.net/Joke/Detail/QSBK/{0}& ...
- python3.7.1安装Scrapy爬虫框架
python3.7.1安装Scrapy爬虫框架 环境:win7(64位), Python3.7.1(64位) 一.安装pyhthon 详见Python环境搭建:http://www.runoob.co ...
- mysql定时任务(event事件)
1.event事件 事件(event)是MySQL在相应的时刻调用的过程式数据库对象.一个事件可调用一次,也可周期性的启动,它由一个特定的线程来管理的,也就是所谓的“事件调度器” 事件和触发器类似,都 ...