码迷,mamicode.com
首页 > 其他好文 > 详细

现有n堆球,其中n是偶数,第i堆中有 ai 个球。现需要将其中 n / 2 堆中的球数全变成完 全平方数,另外的 n / 2 全不为完全平方数。

时间:2018-03-24 20:36:18      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:一个   unity   多少   dad   class   amp   b2c   问题   post   

【问题描述】
现有n堆球,其中n是偶数,第i堆中有 ai 个球。现需要将其中 n / 2 堆中的球数全变成完
全平方数,另外的 n / 2 全不为完全平方数。你每一次操作可以选择任意一堆增加或拿走(前
提不为 0)一个球。试问最少需要多少次操作可以满足要求。
【输入】
第一行输入n (2 ≤n ≤ 200 000)为球的 堆数。
第二行输入𝑛个的非负整数 a1,?a2,?...,?an (0≤?ai ≤?109) 每堆的球数。
【输出】
输出最少的操作步数。
【输入样例】
4
12 14 30 4
【输出样例】
2
【输入样例】
6
0 0 0 0 0 0
【输出样例】
6

http://shijue.me/community/photo-details/c4ef27b44f214e828dad0ded9031e906_d
http://shijue.me/community/photo-details/2eb9ac40ec26489bbaa3aab75e70c42b_d
http://shijue.me/community/photo-details/cf8ab96c8963440996bea744cc5f569b_d
http://shijue.me/community/photo-details/3576e5a5dd354384a68075115bac1f69_d
http://shijue.me/community/photo-details/b35b71b77206445d83b9201dd46afc32_d
http://shijue.me/community/photo-details/de35f29c14624dafb18d6ae224739d99_d
http://shijue.me/community/photo-details/4163b512b5f245e9b6844976d8c6f03d_d
http://shijue.me/community/photo-details/931491144aaa4ff0852f4daff79a0430_d
http://shijue.me/community/photo-details/598d9b1203414433b25a31063d66fd29_d
http://shijue.me/community/photo-details/20febbc8e41a46808ff8b8545aefdbed_d
http://shijue.me/community/photo-details/c3c9d26c8952443ea0488b57264dbbad_d
http://shijue.me/community/photo-details/2756cc15c93c4376bd3da95a3f27e628_d
http://shijue.me/community/photo-details/a2191c1e068f4f23a1018cc11b82fabe_d
http://shijue.me/community/photo-details/82462730dba64eb0952783bef227806e_d
http://shijue.me/community/photo-details/30f5f1b8de6a4998958332fbdeac2969_d
http://shijue.me/community/photo-details/d92ce84fa44b40a4a556d09bd1f6aa27_d
http://shijue.me/community/photo-details/f2dc5e91fee94b2c9de3cd168016e437_d
http://shijue.me/community/photo-details/601a022572404feb9a13d0ac9d3db96a_d
http://shijue.me/community/photo-details/387324aa49364a02b85e2dfd8ec240af_d
http://shijue.me/community/photo-details/dad4e68ee4664f528b6a0b9630a54a31_d
http://shijue.me/community/photo-details/5d762e1b87544fd3a2afbabcadbbe93d_d
http://shijue.me/community/photo-details/9122cf5d76c74e1fb31f2370410a4ae5_d
http://shijue.me/community/photo-details/af0fb1cb0f8a45b299afb3e04481b404_d
http://shijue.me/community/photo-details/83d8d8f57b1a455791febbe2df4427f0_d
http://shijue.me/community/photo-details/bec18d2ce97645fd9abcda1bf1f4ad00_d
http://shijue.me/community/photo-details/628d8a296fc94a55a293de4f7b077f3a_d
http://shijue.me/community/photo-details/4b1632aca49a45f4a4fe36d9748ce5bf_d
http://shijue.me/community/photo-details/305544f9f6c74c1a8e1078ce376e8070_d
http://shijue.me/community/photo-details/5a420d6e19a24cc683b08ac69ab17b8e_d
http://shijue.me/community/photo-details/c50c94fc30f443fd8f7742e97c25107e_d
http://shijue.me/community/photo-details/460d02a991674a65905f635d7bb58e58_d
http://shijue.me/community/photo-details/46fd626e3043415f9b2d751e14491610_d
http://shijue.me/community/photo-details/8f6b9dd484e346ffa728338b290bb1a8_d
http://shijue.me/community/photo-details/e4af92546bdf4054b3d1bcaa3b6231e4_d
http://shijue.me/community/photo-details/2911f9da46674a59a6be22acd56e636d_d
http://shijue.me/community/photo-details/82929ac7b418417fb505f111bbe02cdd_d
http://shijue.me/community/photo-details/e07f8290039847e9ba873524b7b6327d_d

现有n堆球,其中n是偶数,第i堆中有 ai 个球。现需要将其中 n / 2 堆中的球数全变成完 全平方数,另外的 n / 2 全不为完全平方数。

标签:一个   unity   多少   dad   class   amp   b2c   问题   post   

原文地址:https://www.cnblogs.com/dsfsf/p/8640868.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!