Array Product CodeForces - 1042C (细节)】的更多相关文章

#include <iostream> #include <sstream> #include <algorithm> #include <cstdio> #include <math.h> #include <set> #include <map> #include <queue> #include <string> #include <string.h> #include <b…
题意:给出一个数组,2种操作:.1:x*y然后x消失,2:除掉x(2操作最多只能进行一次).问最大的结果的一种操作方式.逻辑题,看能不能想全面. 1先数好0,正,负的数量,zero,pos,neg.如果0数量不为0,在所有0的内部用操作1减少到只剩1个0,zero置1:(删去0不影响结果,如果结果是0,那么剩1个0也能做到,如果结果不是0,那么删0是必须的) 2负数有奇数个时(这种情况下一定有非负解)(1)如果zero=0,用操作2删掉最大的负数(不删结果负,删了必为正)(2)zero=1,用0…
Array Product http://codeforces.com/problemset/problem/1042/C You are given an array aa consisting of nn integers. You can perform the following operations with it: Choose some positions ii and jj (1≤i,j≤n,i≠j1≤i,j≤n,i≠j), write the value of ai⋅ajai⋅…
题目:戳这里 题意:n个数,两种操作,第一种是a[i]*a[j],删掉a[i],第一种是直接删除a[i](只能用一次)剩下的数序列号不变.操作n-1次,使最后剩下的那个数最大化. 解题思路: 正数之间全用操作1得到的结果最大. 负数的个数如果是偶数,全用操作1最后得到的也最大.如果是奇数,那最大的那个负数(贪心的思想)就要进行特殊操作,具体怎么操作要看后面有没有0,如果有0就用操作1去乘,没有就用操作2直接给这个数删了. 有0的话就把所有的0乘最后一个0,然后把最后一个0删了. 附ac代码: 1…
http://codeforces.com/contest/1042/problem/C 给你一个有n个元素序列,有两个操作:1,选取a[i]和a[j],删除a[i],将$a[i]*a[j]$赋值给a[j]2,任意选定一个数删除(只能做一次).打印操作,让最后剩下的数最大. 题意还是比较好理解的. 我们可以想到我们需要先把所有的0,合为一个,然后判断负数两两配对是否多出一个(!%2),两两配对后,两个负数相乘变为正数,正数当然越乘越大. 如果多出一个来,因为要让乘积最大,那么对于负数而言,我们需…
题目 题意: 给你n个数,有两种操作,操作1是把第i个位置的数删去, 操作2 是把 a[ j ]= a[ i ]* a[ j ],把a[ i ]删去 .n-1个操作以后,只剩1个数,要使这个数最大 .要你输出这n-1个步骤. 思路: 结构体储存数和位置, 按值排序,然后分类讨论. 1. 负数个数是奇数,无0  .删除最大的一个负数,别的数正常搞定. 2. 负数个数是奇数,有0  .把最大的一个负数给堆积到最后一个0上,删除最后一个0 . 3. 负数个数是偶数,无0  . 不用删,正常处理. 4.…
B. Makes And The Product time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output After returning from the army Makes received a gift — an array a consisting of n positive integer numbers. He hadn'…
Vasya has an array a consisting of positive integer numbers. Vasya wants to divide this array into two non-empty consecutive parts (the prefix and the suffix) so that the sum of all elements in the first part equals to the sum of elements in the seco…
题目描述 You are given an array aa consisting of nn integers. You can perform the following operations with it: Choose some positions ii and jj ( 1 \le i, j \le n, i \ne j1≤i,j≤n,i≠j ), write the value of a_i \cdot a_jai​⋅aj​ into the jj -th cell and rem…
大意: 给定序列, 给定常数a,b, 两种操作, (1)任选一个长为$t$的子区间删除(不能全部删除), 花费t*a. (2)任选$t$个元素+1/-1, 花费t*b. 求使整个序列gcd>1的最少花费. 题目有个限制是不能全部删除, 所以最后一定剩余a[1]或a[n], 暴力枚举a[1]与a[n]的所有素因子即可. 这场div. 2题目感觉都挺简单的, 但实现起来各种出错...........各种细节还是没考虑好...... #include <iostream> #include &…