题解
1.如果初始乘起来小于等于0,由于操作无法使该乘积更小,所以不用再修改
2.否则代表初始值大于零,随便找一个地方改成 0
3.注意由于 a 很大,所以要用统计的方式来判断乘积的性质
code
#include<bits/stdc++.h>
#define ll long long
using namespace std;
void solve()
{
int n;
cin>>n;
ll fushu=0,ling=0;
for(int i=1;i<=n;i++)
{
ll x;
cin>>x;
if(x<0) fushu++;
else if(x==0) ling++;
}
if(fushu%2==1||ling) cout<<"0\n";
else
{
cout<<"1\n";
cout<<"1 0\n";
}
}
int main()
{
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t=1;
cin>>t;
while(t--) solve();
return 0;
}
标签:Product,int,ll,long,solve,Least
From: https://www.cnblogs.com/pure4knowledge/p/18314175