当前位置:网站首页>0/1 score planning topic
0/1 score planning topic
2022-06-29 20:10:00 【Snow_ raw】
0/1 Fractional programming
- For a class : Each element has two attributes A,B.
- Select several elements , bring ∑ A i ∑ B i \frac{\sum A_i}{\sum B_i} ∑Bi∑Ai Get the maximum value .
- Usually, the dichotomy test is used , Model as appropriate .
- Monotonicity is required .
Word ring
selected from :Acwing lew2018 Analysis of

Code :
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;
const int N = 1010,M=100100;
int h[N],e[M],ne[M],idx,w[M];
bool st[N];
int cnt[N];
double dist[N];
void add(int a,int b,int c){
e[idx]=b;
w[idx]=c;
ne[idx]=h[a];
h[a]=idx++;
}
bool check(double x){
// Average
queue<int>q;
memset(st,0,sizeof st);
memset(cnt,0,sizeof(cnt));
for(int i=0;i<676;i++){
q.push(i);
st[i]=true;
}
int count=0;
while(q.size()){
auto t=q.front();
q.pop();
st[t]=false;
for(int i=h[t];i!=-1;i=ne[i]){
int j=e[i];
if(dist[j]<dist[t]+w[i]-x){
// Positive ring
dist[j]=dist[t]+w[i]-x;
cnt[j]=cnt[t]+1;
// Metaphysical judgment ring
if(++count>10000)return true;
if(cnt[j]>=676)return true;
if(!st[j]){
st[j]=true;
q.push(j);
}
}
}
}
return false;
}
signed main(){
while(cin>>n){
if(!n)break;
memset(h,-1,sizeof h);
string s;
for(int i=1;i<=n;i++){
cin>>s;
if(s.size()>=2){
int left=(s[0]-'a')*26+s[1]-'a';
int right=(s[s.size()-2]-'a')*26+s[s.size()-1]-'a';
int len=s.size();
add(left,right,len);
}
}
if(!check(0))cout<<"No solution"<<endl;
else{
double l=0,r=1000;
while(r-l>=1e-4){
double mid=(r+l)/2;
if(check(mid))l=mid;
else r=mid;
}
cout<<l<<endl;
}
}
return 0;
}
边栏推荐
- Startservice() procedure
- Union find
- There are more than 20 databases in a MySQL with 3306 ports. How can I backup more than 20 databases with one click and do system backup to prevent data from being deleted by mistake?
- 剑指 Offer 59 - II. 队列的最大值
- As the "only" privacy computing provider, insight technology is the "first" to settle in the Yangtze River Delta data element circulation service platform
- 苹果iPhone手机升级系统内存空间变小不够如何解决?
- 【Try to Hack】vulnhub narak
- [boutique] detailed explanation of Pinia
- liunx指令
- Flume theory
猜你喜欢

As the "only" privacy computing provider, insight technology is the "first" to settle in the Yangtze River Delta data element circulation service platform

【编译原理】语法分析
![[fishing artifact] code tool for lowering the seconds of UI Library -- form part (I) design](/img/ad/0efd744334bf648b149aa1841b58af.png)
[fishing artifact] code tool for lowering the seconds of UI Library -- form part (I) design

关于印发宝安区重点产业项目和总部项目遴选及用地保障实施细则(2022修订版)的通知

How to set a pod to run on a specified node

数据链路层

0/1分数规划专题

Regular expression series of mobile phone numbers

Deficiencies and optimization schemes in Dao

Performance improvement at the cost of other components is not good
随机推荐
proxmox集群节点崩溃处理
go: 如何编写一个正确的udp服务端
社区访谈丨一个IT新人眼中的JumpServer开源堡垒机
PHP implementation extracts non repeated integers (programming topics can be the fastest familiar functions)
【U盘检测】为了转移压箱底的资料,买了个2T U盘检测仅仅只有47G~
Flume theory
剑指 Offer 41. 数据流中的中位数
攻防演练中的防守基石——全方位监控
There is no small green triangle on the method in idea
[notes] take notes again -- learn by doing Verilog HDL – 014
Tiger painter mengxiangshun's digital collection is on sale in limited quantities and comes with Maotai in the year of the tiger
Measures to support the development of advanced manufacturing industry in Futian District of Shenzhen in 2022
Is it safe to open a new bond Online
Hangfire details
Notepad++--宏(记录操作过程)
Spark存储体系底层架构剖析-Spark商业环境实战
How to use filters in jfinal to monitor Druid for SQL execution?
Chapter II (physical layer)
一次 Keepalived 高可用的事故,让我重学了一遍它!
[compilation principle] type check