模数之和  AtCoder - 4172  数学

在AtCoder的4172题中,求解给定正整数数组a_1到a_N的情况下,非负整数m的模数之和f(m)的最大值。f(m)定义为m除以每个a_i的余数之和。需找到能最大化f(m)的m值。约束条件包括N的范围及a_i的范围。示例输入和输出展示了如何计算f(m)并找出最大值。
摘要由CSDN通过智能技术生成

F - 模数之和

 AtCoder - 4172 

Problem Statement

 

You are given N positive integers a_1, a_2, ..., a_N.

For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).

Here, X\ mod\ Y denotes the remainder of the division of X by Y.

Find the maximum value of f.

Constraints

 

  • All values in input are integers.
  • 2 \leq N \leq 3000
  • 2 \leq a_i \leq 10^5

Input

 

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_N

Output

 

Print the maximum value of f.

Sample Input 1

 


                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值