AtCoder Beginner Contest 088 (ABC)
A - Infinite Coins
题目链接:https://abc088.contest.atcoder.jp/tasks/abc088_a
Time limit : 2sec / Memory limit : 256MB
Score: 100 points
Problem Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins.
Constraints
- N is an integer between 1 and 10000 (inclusive).
- A is an integer between 0 and 1000 (inclusive).
Input
Input is given from Standard Input in the following format:
N
A
Output
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print Yes
; otherwise, print No
.
Sample Input 1
2018
218
Sample Output 1
Yes
We can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer is Yes
.
Sample Input 2
2763
0
Sample Output 2
No
When we have no 1-yen coins, we can only pay a multiple of 500 yen using only 500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.
Sample Input 3
37
514
Sample Output 3
Yes
#include <iostream>
using namespace std;
int main()
{
int n,a;
while(cin>>n>>a){
int s=n%;
if(s<=a){
cout<<"Yes"<<endl;
}
else cout<<"No"<<endl;
}
return ;
}
B - Card Game for Two
题目链接:https://abc088.contest.atcoder.jp/tasks/abc088_b
Time limit : 2sec / Memory limit : 256MB
Score: 200 points
Problem Statement
We have N cards. A number ai is written on the i-th card.
Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first.
The game ends when all the cards are taken by the two players, and the
score of each player is the sum of the numbers written on the cards
he/she has taken. When both players take the optimal strategy to
maximize their scores, find Alice's score minus Bob's score.
Constraints
- N is an integer between 1 and 100 (inclusive).
- ai (1≤i≤N) is an integer between 1 and 100 (inclusive).
Input
Input is given from Standard Input in the following format:
N
a1 a2 a3 … aN
Output
Print Alice's score minus Bob's score when both players take the optimal strategy to maximize their scores.
Sample Input 1
2
3 1
Sample Output 1
2
First, Alice will take the card with 3. Then, Bob will take the card with 1. The difference of their scores will be 3 - 1 = 2.
Sample Input 2
3
2 7 4
Sample Output 2
5
First, Alice will take the card with 7. Then, Bob will take the card with 4. Lastly, Alice will take the card with 2. The difference of their scores will be 7 - 4 + 2 = 5. The difference of their scores will be 3 - 1 = 2.
Sample Input 3
4
20 18 2 18
Sample Output 3
18
#include <iostream>
#include <algorithm>
using namespace std;
int a[]; bool cmp(int x,int y)
{
return x>y;
} int main()
{
int n;
while(cin>>n){
for(int i=;i<n;i++){
cin>>a[i];
}
sort(a,a+n,cmp);
int sum1=,sum2=;
for(int i=;i<n;i++){
if(i%==) sum1+=a[i];
else sum2+=a[i];
}
cout<<sum1-sum2<<endl;
}
return ;
}
C - Takahashi's Information
题目链接:https://abc088.contest.atcoder.jp/tasks/abc088_c
Time limit : 2sec / Memory limit : 256MB
Score: 300 points
Problem Statement
We have a 3×3 grid. A number ci,j is written in the square (i,j), where (i,j) denotes the square at the i-th row from the top and the j-th column from the left.
According to Takahashi, there are six integers a1,a2,a3,b1,b2,b3 whose values are fixed, and the number written in the square (i,j) is equal to ai+bj.
Determine if he is correct.
Constraints
- ci,j (1≤i≤3,1≤j≤3) is an integer between 0 and 100 (inclusive).
Input
Input is given from Standard Input in the following format:
c1,1 c1,2 c1,3
c2,1 c2,2 c2,3
c3,1 c3,2 c3,3
Output
If Takahashi's statement is correct, print Yes
; otherwise, print No
.
Sample Input 1
1 0 1
2 1 2
1 0 1
Sample Output 1
Yes
Takahashi is correct, since there are possible sets of integers such as: a1=0,a2=1,a3=0,b1=1,b2=0,b3=1.
Sample Input 2
2 2 2
2 1 2
2 2 2
Sample Output 2
No
Takahashi is incorrect in this case.
Sample Input 3
0 8 8
0 8 8
0 8 8
Sample Output 3
Yes
Sample Input 4
1 8 6
2 9 7
0 7 7
Sample Output 4
No
题解:求和然后去掉正对角线的元素 剩下的是正对角线元素的两倍
#include <bits/stdc++.h>
using namespace std;
int a[][];
int main()
{
int sum=,sum1=;
for(int i=;i<;i++){
for(int j=;j<;j++){
cin>>a[i][j];
sum+=a[i][j];
if(i==j) sum1+=a[i][j];
}
}
if(sum-sum1==*sum1) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return ;
}
AtCoder Beginner Contest 088 (ABC)的更多相关文章
- AtCoder Beginner Contest 087 (ABC)
A - Buying Sweets 题目链接:https://abc087.contest.atcoder.jp/tasks/abc087_a Time limit : 2sec / Memory l ...
- AtCoder Beginner Contest 050 ABC题
A - Addition and Subtraction Easy Time limit : 2sec / Memory limit : 256MB Score : 100 points Proble ...
- AtCoder Beginner Contest 088 D Grid Repainting
Problem statement We have an H×W grid whose squares are painted black or white. The square at the i- ...
- AtCoder Beginner Contest 088 C Takahashi's Information
Problem Statement We have a 3×3 grid. A number ci,j is written in the square (i,j), where (i,j) deno ...
- AtCoder Beginner Contest 100 2018/06/16
A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...
- AtCoder Beginner Contest 053 ABCD题
A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...
- AtCoder Beginner Contest 076
A - Rating Goal Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Takaha ...
- AtCoder Beginner Contest 068 ABCD题
A - ABCxxx Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement This contes ...
- AtCoder Beginner Contest 161
比赛链接:https://atcoder.jp/contests/abc161/tasks AtCoder Beginner Contest 161 第一次打AtCoder的比赛,因为是日本的网站终于 ...
随机推荐
- Eclipse ADT中的logcat不显示解决方法
今天维护android的程序,也不知道几百年前写的,elipse,一个日志文件都不显示,做的想哭,我使用的方法二,这里给自己留一个备份,怕再忘记了 1.在Eclipse界面中找到DDMS,然后找到 ...
- 爬虫请求库——selenium
selenium模块 selenium最初是一个自动化测试工具,而爬虫中使用它主要是为了解决requests无法直接执行JavaScript代码的问题.selenium的缺点是效率会变得很慢. sel ...
- tomcat调试之固定步骤自动化
前端开发,使用tomcat调试,大致需要进行如下几个步骤.其中,第一步,进入项目所在目录敲sbt命令来打包,第二步,拷贝lib文件夹,第四步重启tomcat,反反复复已经让我不胜其烦,那么做个简单的b ...
- 多线程——newCachedThreadPool线程池
newCachedThreadPool线程池: 理解: 1).newCachedThreadPool可以创建一个无限大小的线程池(实际上是一个可缓存线程池). 可以通过Executors的静 ...
- Mac charles 抓取https请求,安装证书后还是显示unknown
https://blog.csdn.net/qq_23114525/article/details/81460840 1. 配置证书 2. 设置钥匙串信任 3. 设置手机代理 端口号需要对应设置的端口 ...
- Mac提醒事项如何设置为24小时制
- Oracle查看用户密码过期,修改永不过期
01.查看当前open用户 select username,account_status,expiry_date,profile from dba_users; 02.查看目前的密码过期策略 sele ...
- Django 框架 数据库操作
数据库与ORM 1 django默认支持sqlite,mysql, oracle,postgresql数据库. <1> sqlite django默认使用sqlite的数据库,默认 ...
- 第二弹:超全Python学习资源整理(进阶系列)
造一个草原要一株三叶草加一只蜜蜂.一株三叶草,一只蜂,再加一个梦.要是蜜蜂少,光靠梦也行. - 狄金森 "成为编程大牛要一门好语言加一点点天分.一门好语言,一点点天分,再加一份坚持.要是天分 ...
- 8款不错的 CI/CD工具
Jenkins Jenkins是CI市场中最知名且最常见的名号之一.其最初是由Sun公司的一位工程师打造的一个辅助项目,并迅速扩展为最大的开源CI工具之一,可帮助工程团队实现自动化部署.顺带一提:我们 ...