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. 程序员接私活经验总结,来自csdn论坛语录

    以下为网上摘录,以做笔记: 可是到网上看看,似乎接私活也有很多不容易,技术问题本身是个因素,还有很多有技术的人接私活时被骗,或者是合作到最后以失败告终,所以想请有经验的大侠们出来指点一下,接私活是怎么 ...

  2. kettle6.1如何连接mongodb

    . Kettle的结构图如下: 2.介绍各个组件详细情况 表输入:通常是你的sql语句,这个会Kettle基础知识的都会不介绍了 JSON Output如下: MogoDB output如下: 下面这 ...

  3. Linux Shell | 解析xml节点

    01 xml文件 # user.xml <user> <name>Toy</name> <sex>man</sex> <room/&g ...

  4. sqlite修改表、表字段等与sql server的不同之处

    sqlite中只支持 ALTER TABLE 命令的 RENAME TABLE 和 ADD COLUMN. 其他类型的 ALTER TABLE 操作如 DROP COLUMN,ALTER COLUMN ...

  5. mybatis什么时候必须指定jdbcType

    #{property,javaType=int,jdbcType=NUMERIC}如果一个列允许 null 值,并且会传递值 null 的参数,就必须要指定 JDBC Type

  6. Look into Bitmap images

    What's a Bitmap image? I'm not going to explain the differences between raster and vector images, no ...

  7. VS 使用 :新建项目

    1.文件位置不放C盘

  8. 将训练集构建成ImageNet模型

    以下程序实现将训练集构建为ImageNet模型,训练集图片为56个民族 import java.io.File; import java.io.FileNotFoundException; impor ...

  9. nyoj 7 街区最短路径问题 (曼哈顿距离(出租车几何) or 暴力)

    街区最短路径问题 时间限制:3000 ms  |  内存限制:65535 KB 难度:4   描述 一个街区有很多住户,街区的街道只能为东西.南北两种方向. 住户只可以沿着街道行走. 各个街道之间的间 ...

  10. flex一些属性

    // 改变主轴的方向 flex-direction: column; // display:flex的子元素无法设置宽度 // 子元素有个flex-shrink属性,表示在父元素宽度不够的情况下是否自 ...