A - Buying Sweets

题目链接:https://abc087.contest.atcoder.jp/tasks/abc087_a

Time limit : 2sec / Memory limit : 256MB

Score : 100 points

Problem Statement

You went shopping to buy cakes and donuts with X yen (the currency of Japan).

First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop.

How much do you have left after shopping?

Constraints

  • 1≤A,B≤1 000
  • A+BX≤10 000
  • X, A and B are integers.

Input

Input is given from Standard Input in the following format:

X
A
B

Output

Print the amount you have left after shopping.


Sample Input 1

Copy
1234
150
100

Sample Output 1

Copy
84

You have 1234−150=1084 yen left after buying a cake. With this amount, you can buy 10 donuts, after which you have 84 yen left.


Sample Input 2

Copy
1000
108
108

Sample Output 2

Copy
28

Sample Input 3

Copy
579
123
456

Sample Output 3

Copy
0

Sample Input 4

Copy
7477
549
593

Sample Output 4

Copy
405
     #include<bits/stdc++.h>
using namespace std; int main()
{
int x,a,b;
while(cin>>x>>a>>b){
x-=a;
x%=b;
cout<<x<<endl;
}
return ;
}

B - Coins

题目链接:https://abc087.contest.atcoder.jp/tasks/abc087_b

Time limit : 2sec / Memory limit : 256MB

Score : 200 points

Problem Statement

You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total?

Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.

Constraints

  • 0≤A,B,C≤50
  • A+B+C≥1
  • 50≤X≤20 000
  • A, B and C are integers.
  • X is a multiple of 50.

Input

Input is given from Standard Input in the following format:

A
B
C
X

Output

Print the number of ways to select coins.


Sample Input 1

Copy
2
2
2
100

Sample Output 1

Copy
2

There are two ways to satisfy the condition:

  • Select zero 500-yen coins, one 100-yen coin and zero 50-yen coins.
  • Select zero 500-yen coins, zero 100-yen coins and two 50-yen coins.

Sample Input 2

Copy
5
1
0
150

Sample Output 2

Copy
0

Note that the total must be exactly X yen.


Sample Input 3

Copy
30
40
50
6000

Sample Output 3

Copy
213

题解:找零钱
     #include<bits/stdc++.h>
using namespace std; int main()
{
int x,a,b,c;
while(cin>>a>>b>>c>>x){
x/=;
int sum=;
for(int i=;i<=a;i++){
for(int j=;j<=b;j++){
for(int k=;k<=c;k++){
if(i*+j*+k==x) sum++;
}
}
}
cout<<sum<<endl;
}
return ;
}

C - Candies

题目链接:https://abc087.contest.atcoder.jp/tasks/arc090_a

Time limit : 2sec / Memory limit : 256MB

Score : 300 points

Problem Statement

We have a N grid. We will denote the square at the i-th row and j-th column (1≤i≤2, 1≤jN) as (i,j).

You are initially in the top-left square, (1,1). You will travel to the bottom-right square, (2,N), by repeatedly moving right or down.

The square (i,j) contains Ai,j candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them.

At most how many candies can you collect when you choose the best way to travel?

Constraints

  • 1≤N≤100
  • 1≤Ai,j≤100 (1≤i≤2, 1≤jN)

Input

Input is given from Standard Input in the following format:

N
A1,1 A1,2 A1,N
A2,1 A2,2 A2,N

Output

Print the maximum number of candies that can be collected.


Sample Input 1

Copy
5
3 2 2 4 1
1 2 2 2 1

Sample Output 1

Copy
14

The number of collected candies will be maximized when you:

  • move right three times, then move down once, then move right once.

Sample Input 2

Copy
4
1 1 1 1
1 1 1 1

Sample Output 2

Copy
5

You will always collect the same number of candies, regardless of how you travel.


Sample Input 3

Copy
7
3 3 4 5 4 5 3
5 3 4 4 2 3 2

Sample Output 3

Copy
29

Sample Input 4

Copy
1
2
3

Sample Output 4

Copy
5

题解:分成两个数组 同时使用前缀和 取最大值
     #include<bits/stdc++.h>
using namespace std;
int a[],b[];
int suma[],sumb[];
int main()
{
int n;
while(cin>>n){
for(int i=;i<n;i++){
cin>>a[i];
}
for(int i=;i<n;i++){
cin>>b[i];
}
suma[]=a[];sumb[]=b[];
for(int i=;i<n;i++){
suma[i]=suma[i-]+a[i];
sumb[i]=sumb[i-]+b[i];
}
int maxn=suma[]+sumb[n-];
for(int i=;i<n;i++){
int sum=suma[i]+sumb[n-]-sumb[i-];
maxn=max(maxn,sum);
}
cout<<maxn<<endl;
}
return ;
}


AtCoder Beginner Contest 087 (ABC)的更多相关文章

  1. AtCoder Beginner Contest 088 (ABC)

    A - Infinite Coins 题目链接:https://abc088.contest.atcoder.jp/tasks/abc088_a Time limit : 2sec / Memory ...

  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 087 D - People on a Line

    Time limit : 2sec / Memory limit : 256MB Score : 400 points Problem Statement There are N people sta ...

  4. AtCoder Beginner Contest 087 B - Coins

    Time limit : 2sec / Memory limit : 256MB Score : 200 points Problem Statement You have A 500-yen coi ...

  5. AtCoder Beginner Contest 087 D People on a Line(DFS)

    题意 给出n个点,m组关系L,R,D,L在R的左边距离D,判断是否存在n个人的位置满足m组关系 分析 Consider the following directed graph G: There ar ...

  6. AtCoder Beginner Contest 100 2018/06/16

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

  7. AtCoder Beginner Contest 053 ABCD题

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

  8. AtCoder Beginner Contest 076

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

  9. AtCoder Beginner Contest 068 ABCD题

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

随机推荐

  1. python安装talib库

    简便安装方法 最简单的安装方式: $ pip install TA-Lib 用setup.py的方式自己安装一个源文件 $ python setup.py install 有可能遇到的问题 func. ...

  2. 004-RestTemplate 使用常见问题

    一.使用 同前三节:ClientGetGoodsByGoodsIdResponse response = restTemplate.postForObject(svcUrl, request, Res ...

  3. MySQL 基础 备份和恢复

    数据库备份 mysqldump [args] > file_name 例如:备份所有数据库 shell> mysqldump --all-databases > dump.sql # ...

  4. PS教程:如何批量处理图片

    1.我们先准备两个文件夹,一个用来装你要处理的图片,可以是几百上千张,另一个是空文件夹,用来装等下处理好的图片. 2.打开PS,打开未处理文件夹里的任何一张图片. 3. 在红圈中点击,新建一个动作. ...

  5. Firewalld防火墙:端口转发与流量均衡

    firewalld和iptables的关系 firewalld自身并不具备防火墙的功能,而是和iptables一样需要通过内核的netfilter来实现,也就是说firewalld和iptables一 ...

  6. Selenium基础知识(六)下拉列表定位

    1.下拉列表定位 要选择下拉列表中的元素,要先定位到,下拉列表元素,然后可以通过xpath去点击,表内内容 例如,百度搜索-->百度设置-->搜索设置-->选择下拉列表框内" ...

  7. oracle 常用(二)

    多表查询: 1.等值连接查询: select a.aa,a.bb,b.qq from XX  a ,   CC  b   where a.aa= b.ee 2.不等值连接: select  *  fr ...

  8. css属性 background

    background 在一个声明中设置所有的背景属性. background-attachment 设置背景图像是否固定或者随着页面的其余部分滚动. background-color 设置元素的背景颜 ...

  9. java.lang.ClassNotFoundException: org.hibernate.engine.FilterDefinition的解决方案

    今天在GitHub上面看到一个有意思的项目,下载下来,使用tomcat部署失败,出现异常,网上说JDK版本太高,改低,还是失败. 由于本人有个习惯,更喜欢把项目直接放入tomcat webapps 里 ...

  10. powerdesign、navacat、ER图、uml、类图、时序图

    关于建表和生成实体以及ER图的简便方法 a:用navacat客户端生成简单的ER图,并生成建表sql,执行生成表. b:用powerdesign连接数据库,反向生成带有注释的ER图. c:用ideal ...