当前位置:网站首页>Noi OJ 1.3 15: apple and bug C language

Noi OJ 1.3 15: apple and bug C language

2022-06-23 10:29:00 chd44

describe

You bought a box of n An apple , Unfortunately, there was a bug in the box when I bought it . Every insect x You can eat an apple in an hour , Suppose the insect doesn't eat one apple before eating another , So after y How many complete apples do you have in an hour ?

Input

Enter only one line , Include n,x and y( All are integers ). Input data guarantee y <= n * x.

Output

The output is only one line , The number of apples left

The idea of this question should also bring the idea of seeking remainder into it , Make it clear when to -1.

#include<stdio.h>
int main(){
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
int d=a-c/b;
int e=c%b;
if(e==0)
    printf("%d",d);
else
    printf("%d",d-1);
return 0;
}

notes : Limited topics , It doesn't need to be considered that the calculation result will be <0 The situation of .

原网站

版权声明
本文为[chd44]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206231012356282.html