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

Copy
2018
218

Sample Output 1

Copy
Yes

We can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer is Yes.


Sample Input 2

Copy
2763
0

Sample Output 2

Copy
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

Copy
37
514

Sample Output 3

Copy
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≤iN) 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

Copy
2
3 1

Sample Output 1

Copy
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

Copy
3
2 7 4

Sample Output 2

Copy
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

Copy
4
20 18 2 18

Sample Output 3

Copy
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

Copy
1 0 1
2 1 2
1 0 1

Sample Output 1

Copy
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

Copy
2 2 2
2 1 2
2 2 2

Sample Output 2

Copy
No

Takahashi is incorrect in this case.


Sample Input 3

Copy
0 8 8
0 8 8
0 8 8

Sample Output 3

Copy
Yes

Sample Input 4

Copy
1 8 6
2 9 7
0 7 7

Sample Output 4

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

  1. AtCoder Beginner Contest 087 (ABC)

    A - Buying Sweets 题目链接:https://abc087.contest.atcoder.jp/tasks/abc087_a Time limit : 2sec / Memory l ...

  2. AtCoder Beginner Contest 050 ABC题

    A - Addition and Subtraction Easy Time limit : 2sec / Memory limit : 256MB Score : 100 points Proble ...

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

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

  5. AtCoder Beginner Contest 100 2018/06/16

    A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...

  6. AtCoder Beginner Contest 053 ABCD题

    A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...

  7. AtCoder Beginner Contest 076

    A - Rating Goal Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Takaha ...

  8. AtCoder Beginner Contest 068 ABCD题

    A - ABCxxx Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement This contes ...

  9. AtCoder Beginner Contest 161

    比赛链接:https://atcoder.jp/contests/abc161/tasks AtCoder Beginner Contest 161 第一次打AtCoder的比赛,因为是日本的网站终于 ...

随机推荐

  1. Python3学习之路~0 目录

    目录 Python3学习之路~2.1 列表.元组操作 Python3学习之路~2.2 简单的购物车程序 Python3学习之路~2.3 字符串操作 Python3学习之路~2.4 字典操作 Pytho ...

  2. 打开Delphi 10.1 berlin提示脚本错误的解决方法

    HKEY_CURRENT_USER\SOFTWARE\Embarcadero\BDS\18.0\Known IDE Packages $(BDS)\Bin\CommunityToolbar240.bp ...

  3. python实现根据当前时间创建目录并输出日志

    举个例子:比如我们要实现根据当前时间的年月日来新建目录来存放每天的日志,当前时间作为日志文件名称:代码如下: #!/usr/bin/env python3 # _*_ coding: utf-8 _* ...

  4. 007-docker-安装-mysql:5.6

    1.搜索镜像 docker search mysql 2.拉取合适镜像 docker pull mysql:5.6 docker images 3.使用镜像 docker run -p 3306:33 ...

  5. vue中computed和watch的用法

    computed用来监控自己定义的变量,该变量不在data里面声明,直接在computed里面定义,然后就可以在页面上进行双向数据绑定展示出结果或者用作其他处理: computed比较适合对多个变量或 ...

  6. Stylus的使用

    vue-cli项目安装使用stylus步骤:1. npm install stylus -D命令,在项目内安装stylus.(注意:命令结尾 -D 即是 --save-dev 的简写形式) 2.需要安 ...

  7. 列表 list 容器类型数据(str字符串, list列表, tuple元组, set集合, dict字典)--->元组 tuple-->字符串 str

    # ### 列表 list 容器类型数据(str字符串, list列表, tuple元组, set集合, dict字典) # (1)定义一个列表 listvar = [] print(listvar, ...

  8. 多态使用时,父类多态时需要使用子类特有对象。需要判断 就使用instanceof

    instanceof:通常在向下转型前用于健壮性的判断,判断是符合哪一个子类对象 package Polymorphic; public class TestPolymorphic { public ...

  9. [LeetCode] 849. Maximize Distance to Closest Person_Easy tag: BFS

    In a row of seats, 1 represents a person sitting in that seat, and 0 represents that the seat is emp ...

  10. 机器人meta标签和X-Robots-Tag HTTP标头规格

    抽象 本文档详细介绍了页级索引设置如何让您控制Google如何通过搜索结果提供内容.您可以通过在(X)HTML页面或HTTP标头中包含元标记来指定这些标记. 笔记 请注意,只有当抓取工具被允许访问包含 ...