当前位置:网站首页>[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
边栏推荐
- 动态代理ip的测试步骤有哪些?
- Shardingsphere broadcast table and binding table
- Unicorn bio raised $3.2 million to turn prototype equipment used to grow meat into commercial products
- 搭建网站是用物理机还是云主机好?
- Keil MDK Chinese garbled code, two solutions, the font is no longer ugly
- 什么是api接口?
- LeetCode 349. Intersection of two arrays (simple, array) Day12
- 009_Redis_RedisTemplate入门
- What categories do you need to know before using proxy IP?
- Consider defining a bean of type ‘com.netflix.discovery.AbstractDiscoveryClientOptionalArgs‘
猜你喜欢

Network jitter tool clumsy

What are the test steps of dynamic proxy IP?

搭建个人主页保姆级教程(二)

拨号vps会遇到什么问题?

搭建网站是用物理机还是云主机好?

What business scenarios will the BGP server be used in?

使用代理IP是需要注意什么?

Cc2541 emulator CC debugger tutorial

What categories do you need to know before using proxy IP?

89 logistic regression user portrait user response prediction
随机推荐
Introduction to esp32 Bluetooth controller API
OJ daily practice - Finish
每日一题(2022-04-21)——山羊拉丁文
VMware virtual machine installation openwrt as side route single arm route img image to vmdk
Common formatting problems after word writing
【ValueError: math domain error】
搭建网站是用物理机还是云主机好?
How to "gracefully" measure system performance
Is CICC fortune a state-owned enterprise and is it safe to open an account
Easyswool environment configuration
Wechat public platform test number application, authorized login function and single sign on using hbuilder X and wechat developer tools
PTA: 点赞狂魔
Use Xdebug breakpoint debugging in postman
如何选择一台好的拨号服务器?
How to configure iptables to realize local port forwarding
What is a makefile file?
2018 China Collegiate Programming Contest - Guilin Site J. stone game
Micro build low code zero foundation introductory course
Redis memory recycling strategy
Talk about biology live broadcast: Dr. Wang Ziyuan, a lake view biology, exploring hepatitis B with gene therapy