Gym-101502A A Very Hard Question
题意:
橘子的价格增长了x%,问用同样多的钱,过去能买y个橘子现在还能买多少个?
保证所有的答案都是整数,不要输出浮点值。
做法:
我们假设橘子价格为a元/个,买橘子的钱不变,现在还能够买ans个橘子,
所以y*a = ans*a(1+x%),ans可求。注意一下float的使用。
#include <stdio.h>
int
main() {
int t, y, x, ans;
scanf("%d", &t);
while( t-- ) {
scanf("%d %d", &y, &x);
ans = 1.0 * y / (1 + x * 0.01) + 0.5;
printf("%d\n", ans);
}
return 0;
}