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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块

    Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块 [Problem Description] ​ ...

  6. 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 ...

  7. 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 ...

  8. Educational Codeforces Round 43 (Rated for Div. 2)

    Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...

  9. Educational Codeforces Round 35 (Rated for Div. 2)

    Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...

随机推荐

  1. Java描述设计模式(18):享元模式

    本文源码:GitHub·点这里 || GitEE·点这里 一.使用场景 应用代码 public class C01_InScene { public static void main(String[] ...

  2. Subline Text3最新激活方法解决 That license key doesn't appear to be valid.

    第一步: 管理员身份登录系统 第二步: 进入到 C:\Windows\System32\drivers\etc (这个路径可以复制,都是一样的) 第三步: 右键hosts这个文件(打开方式 - 选择记 ...

  3. 基于docker搭建Jenkins+Gitlab+Harbor+Rancher架构实现CI/CD操作

    一.各个组件的功能描述: Docker 是一个开源的应用容器引擎. Jenkis 是一个开源自动化服务器. (1).负责监控gitlab代码.gitlab中配置文件的变动: (2).负责执行镜像文件的 ...

  4. 使用 Zephir 轻松构建 PHP 扩展

    简介: 通过 PHP 扩展, 我们可以在 php 代码中使用一些特定的方法(大部分的 php 扩展都是用 C 写的). 比如,在 PHP 中需要与 SQLite3 交互,我们可以自己写方法与之进行连接 ...

  5. thinkphp 比RBAC更好的权限认证方式(Auth类认证)

    Auth 类已经在ThinkPHP代码仓库中存在很久了,但是因为一直没有出过它的教程, 很少人知道它, 它其实比RBAC更方便 . RBAC是按节点进行认证的,如果要控制比节点更细的权限就有点困难了, ...

  6. [高效工作软件] Capslock+的使用笔记 (快捷键)

    1.下载https://cjkis.me/capslock+/#%E4%B8%8B%E8%BD%BD,双击即可安装,中文路径也可: 2.这个软件的代码开源了的,以后java学成之后,可以去看看源码: ...

  7. C语言程序设计100例之(14):丑数

    例14   丑数 问题描述 丑数是其质因子只可能是2,3或5的数.前10个丑数分别为1, 2, 3, 4, 5, 6, 8, 9, 10, 12.输入一个正整数n,求第n个丑数. 输入格式 每行为一个 ...

  8. nyoj 42-一笔画问题 (欧拉图 && 并查集)

    42-一笔画问题 内存限制:64MB 时间限制:3000ms Special Judge: No accepted:10 submit:25 题目描述: zyc从小就比较喜欢玩一些小游戏,其中就包括画 ...

  9. nyoj 596-谁是最好的Coder (greater, less)

    596-谁是最好的Coder 内存限制:64MB 时间限制:1000ms 特判: No 通过数:15 提交数:28 难度:0 题目描述: 计科班有很多Coder,帅帅想知道自己是不是综合实力最强的co ...

  10. django_4:数据库0——配置数据库

    使用Mysql数据库 (python需要能连接上mysql,见别的文档:python3+django 支持 mysql) 启动mysql服务 修改setting.py同目录 下的__init__.py ...