codeforces 546A-C语言解题报告
发布日期:2021-05-07 02:43:18 浏览次数:19 分类:精选文章

本文共 404 字,大约阅读时间需要 1 分钟。

题目解析

1.输入 k(成本),n(拥有的钱),w(要买的个数),输出还需要向朋友借多少钱?

举例:
输入:
3 17 4
输出:
13

2.注意:

1)第i个,需要i*k个价钱,所以需要使用for循环运算花费
2)当拥有的钱足够买时,不需要借钱,输出为0

代码

#include
#include
#include
int main(){ int k,n,w,count=0,need=0; scanf("%d %d %d",&k,&n,&w); for(int i=1;i<=w;i++) { count+=i*k; } if(count-n>0) { need=count-n; }else need =0; printf("%d",need); system("pause"); getchar(); return 0;}
上一篇:JDBCUtils代码
下一篇:远程连接Ubuntu Server的mysql

发表评论

最新留言

路过按个爪印,很不错,赞一个!
[***.219.124.196]2025年04月15日 13时35分09秒