当前位置:网站首页>[NK] Niuke monthly race 48 D
[NK] Niuke monthly race 48 D
2022-04-23 02:08:00 【RISE_ lower】
The question
Given a n n n Of length a [ ] a[] a[], You can Arbitrary arrangement a [ ] a[] a[]
Finally make Alternating multiplication Maximum ( What is this? Look at the question )
Ideas
greedy
apparent ( Of course not. , I only say hi after the game
obviously We let And the largest number first add , Then calculate later Multiplication When , Contribution is the greatest
So we consider ( Big * Big )* Big + Small
400 400 400 Many people are greedy , Feel this greedy It's strange
code
c o s e c a n t cosecant cosecant The bosses
const int N = 1e5+10 ,mod = 1e9+7;
int a[N],n,b[N];
void solve(){
cin>>n;
for(int i=1;i<=n;i++) cin>>b[i];
sort(b+1,b+1+n);
int j = 1;
// even numbers Used to add ( Put the small one in the back and add )
for(int i=n/2*2;i>=2;i-=2) a[i] = b[j++];
// Odd number Used to ride ( Put the big one in front of you )
for(int i=1;i<=n;i+=2) a[i] = b[j++];
int s = a[1];
for(int i=2;i<=n;i++){
if(i&1){
// When it's odd It's multiplication
s = 1ll*s*a[i]%mod;
}else{
// Even numbers are added
s = (s+a[i])%mod;
}
}
cout<<s<<endl;
}
版权声明
本文为[RISE_ lower]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230206445393.html
边栏推荐
猜你喜欢

校园转转二手市场源码

leetcode:27. 移除元素【count remove小操作】

89 logistic regression user portrait user response prediction
![leetcode:27. Remove element [count remove]](/img/af/e5cd9ef8dc43aab4ddf016600ffc4a.png)
leetcode:27. Remove element [count remove]

What is a proxy IP pool and how to build it?

What businesses use physical servers?

Heap overflow of kernel PWN basic tutorial

Leetcode40 - total number of combinations II

Micro build low code zero foundation introductory course

Batch multiple files into one hex
随机推荐
Network jitter tool clumsy
What is an API interface?
如何选择一台好的拨号服务器?
New book recommendation - IPv6 technology and application (Ruijie version)
Halo open source project learning (I): project launch
每日一题(2022-04-22)——旋转函数
005_redis_set集合
Communication summary between MCU and 4G module (EC20)
世界读书日 | 技术人不要错过的好书(IT前沿技术)
001_redis设置存活时间
Summary of I / O knowledge points
Makefile文件是什麼?
2018 China Collegiate Programming Contest - Guilin Site J. stone game
Use of push() and pop()
Is CICC fortune a state-owned enterprise and is it safe to open an account
Analyze the three functions of static proxy IP.
arduino esp8266 网络升级 OTA
Talk about biology live broadcast: Dr. Wang Ziyuan, a lake view biology, exploring hepatitis B with gene therapy
Consider defining a bean of type ‘com.netflix.discovery.AbstractDiscoveryClientOptionalArgs‘
Why is one plus one equal to two