当前位置: 首页 > news >正文

在线销售网站设计文献wordpress 付费主题 时间

在线销售网站设计文献,wordpress 付费主题 时间,网站的关键字 设置,如何推广自己的网站和产品Description 有n个小朋友坐成一圈#xff0c;每人有ai个糖果。每人只能给左右两人传递糖果。每人每次传递一个糖果代价为1。 Input 第一行一个正整数nn1000000#xff0c;表示小朋友的个数#xff0e;接下来n行#xff0c;每行一个整数ai#xff0c;表示第i个小朋友得…Description 有n个小朋友坐成一圈每人有ai个糖果。每人只能给左右两人传递糖果。每人每次传递一个糖果代价为1。 Input 第一行一个正整数nn1000000表示小朋友的个数 接下来n行每行一个整数ai表示第i个小朋友得到的糖果的颗数 Output 求使所有人获得均等糖果的最小代价。 Sample Input 4 1 2 5 4 Sample Output 4 这道题让我想到了白书上面的相似的一道题 UVA11300 Spreading the Wealth A Communist regime is trying to redistribute wealth in a village. They have have decided to sit everyone around a circular table. First, everyone has converted all of their properties to coins of equal value, such that the total number of coins is divisible by the number of people in the village. Finally, each person gives a number of coins to the person on his right and a number coins to the person on his left, such that in the end, everyone has the same number of coins. Given the number of coins of each person, compute the minimum number of coins that must be transferred using this method so that everyone has the same number of coins. Input There is a number of inputs. Each input begins with n (n 1000001), the number of people in the village. n lines follow, giving the number of coins of each person in the village, in counterclockwise order around the table. The total number of coins will fit inside an unsigned 64 bit integer. Output For each input, output the minimum number of coins that must be transferred on a single line. Sample Input 3 100 100 100 4 1 2 5 4 Sample Output 0 4 题意个人围成一圈每个人都有一些硬币每个人只能给左右相邻的人硬币问最少交换几个硬币使每个人硬币一样多。 我第一反应费用流。第二反应费用流。第三反应费用流。 然后看uva11300题解 首先最终每个人金币数量可以计算出来我们用M表示每个人最后拥有的金币数。 我们对于第i个人可以看作他给了他左边的人xi个金币负数表示反向传递他右边的人给了他xi1个金币假设他一开始拥有的金币数量为Ai那么有Ai-xixi1M。 如果我们继续列下去就会变成这样 A1-x1x2M - x2M-A1x1 -  令C1A1-M - x2x1-C1 A2-x2x3M - x3M-A2x22*M-A1-A2x1 -  令C2A1A2-2*M - x3x1-C2 A3-x3x4M - x4M-A3x33*M-A1-A2-A3x1 -  令C3A1A2A3-3*M - x4x1-C3 ....... 那么我们就会得到n个等式但是我们发现我们可以用这n个等式中的任意n-1个去变换得到最后剩下那个等式。 因为我们知道 $\sum A_i M \times n $ 那么最后一个等式Cn0就是x1x1。 也就是说最后那个等式是没有用的我们只会用到n-1个等式。那么这n-1个等式可以用来做什么呢我们怎样才能求得 $ \sum abs(x_i) $ 最小值呢 $ \sum abs( x_i ) abs( x_1 )abs( x_2 )abs( x_3 )......abs( x_n )abs( x_1 ) abs(x_1-C_1) abs(x_1- C_2) ......abs(x_1-C_{n-1})$ 由于Ci是可以直接计算出来的可以当作常数所以说这个等式相当于是求一个最优的x1使得数轴上x1到Ci距离和最小而这个距离和就是我们所求的答案。 最后问题转化成求数轴上一个点到所有已知的点最小距离相信在小学或是初中数学老师都讲过这样的点就是中位数啦。 然后就直接算出C然后算中位数与其他的所有的点的距离。 bzoj1045 代码 //Serene #includealgorithm #includeiostream #includecstring #includecstdlib #includecstdio #includecmath using namespace std; const int maxn1e610; long long n,tot,ans,c,A[maxn],C[maxn];long long aa;char cc; long long read() {aa0;ccgetchar();while(cc0||cc9) ccgetchar();while(cc0cc9) aaaa*10cc-0,ccgetchar();return aa; }int main() {nread();for(int i1;in;i) A[i]read(),totA[i];tot/n;for(int i1;in;i) C[i]A[i]-totC[i-1];sort(C1,Cn1);//还有一个C[i]为0的 for(int i1;in;i) ansabs(C[i]-C[(n1)1]);printf(%lld,ans);return 0; }转载于:https://www.cnblogs.com/Serene-shixinyi/p/7594077.html
http://www.zqtcl.cn/news/464579/

相关文章:

  • WordPress子站站群建筑工程网上申请质量安全监督
  • 怎么给网站添加图标山西手机版建站系统哪家好
  • frontpage网页制作视频教程昆明网站建设优化企业
  • 工信部 诚信网站备案公司网络营销方案
  • 网站开发采集工具如何做网站内链优化
  • 在线做英语题的网站揭阳建站服务
  • 网站非法篡改wordpress的知名网站
  • 保定网建站模板uv推广平台
  • 股权分配系统建设网站wordpress mip 模板
  • 网站及其建设的心得体会昆明云南微网站
  • 详情页在线设计网站推荐广州建设网站企业
  • 设计师网站建设哪家网络公司做网站
  • 宣城网站开发专业制注册资金写100万后悔
  • 专业的高密做网站的建公司网站要多久
  • 蚌埠做网站哪家好WordPress强制ssl
  • 1m宽带做网站平台建站
  • 学习做ppt 的网站班会活动设计方案模板
  • 廊坊住房和城乡建设厅网站门户网站开发招标
  • 免费下载网站设计方案wordpress zenmeyong
  • 网站建设与维护相关知识网站建设遵循的规范
  • 网站建设费科目东莞市塘厦镇
  • 网站建设策划书1万字深圳公司网站设计企业
  • 建设企业网站小微asp iis设置网站路径
  • 分类信息网站营销小程序appid是什么
  • 营销软文是什么意思网络seo培训
  • 效果好的手机网站建设成都网站制作报价
  • 江门网站建设推广平台注册公司费用要多少
  • 淄博哪家公司做网站最好新手做地方门户网站
  • 做一个交易平台网站的成本深圳南山做网站的公司
  • 网站建设的开发的主要方法aspcms分类信息网站