Tyvj 1921 Freda的烦恼

本文介绍了一个关于数学函数应用的程序设计题目解析,通过自定义最小值函数min来解决特定问题,利用输入输出操作实现成本计算逻辑。文章通过具体代码示例展示了如何处理多种条件下的最优解计算。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我就不说是CF hot days 原题了,我会告诉你使用Math库是因为一开始偷懒不想写Min函数么-
 1 Uses math;
 2 Var n,m,i,t,tt,x,cost,ans,tmp:qword;
 3 Function min(x,y:qword):qword;
 4 Begin
 5   if x>y then exit(y);
 6   exit(x);
 7 end;
 8 Begin
 9    readln(n,m);
10    while (n<>0do
11    Begin
12      dec(n);
13      readln(t,tt,x,cost);
14      if (tt<=t) then
15      begin
16        ans:=ans+cost;
17        continue;
18      end;
19      if (m mod (tt-t)=0then tmp:=cost*trunc((m/(tt-t)))
20      else tmp:=cost*trunc((m/(tt-t)+1));
21      ans:=ans+min(m*x+cost,tmp);
22    end;
23    writeln(ans);
24 end.
-

转载于:https://www.cnblogs.com/shy-/archive/2012/09/11/2680757.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值