您当前的位置: 首页 > 

MangataTS

暂无认证

  • 0浏览

    0关注

    423博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

AtCoder Beginner Contest 173 A - Payment

MangataTS 发布时间:2020-07-12 20:47:00 ,浏览量:0

A - Payment

Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 100100 points

Problem Statement

We will buy a product for NN yen (the currency of Japan) at a shop.

If we use only 10001000-yen bills to pay the price, how much change will we receive?

Assume we use the minimum number of bills required.

Constraints
  • 1≤N≤100001≤N≤10000
  • NN is an integer.
Input

Input is given from Standard Input in the following format:

NN

Output

Print the amount of change as an integer.

Sample Input 1 Copy
Copy
1900

Sample Output 1 Copy
Copy
100

We will use two 1000-yen bills to pay the price and receive 100 yen in change.

Sample Input 2 Copy
Copy
3000

Sample Output 2 Copy
Copy
0

We can pay the exact price.

题意:给你一个数,算出找零的数(其实原文更容易看懂)

解题思路:对n用1k求余如果余数为0则不用找钱(给的钱刚好为1k的整数倍),否则就要找1k-n%1k的零钱

代码如下:

#include
int main(void)
{
    int n;
    while(~scanf("%d",&n))
    printf("%d\n",n%1000==0?0:1000-n%1000);
    return 0;
}
关注
打赏
1665836431
查看更多评论
立即登录/注册

微信扫码登录

0.0346s