当前位置:网站首页>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;
}
边栏推荐
- 并查集(Union-Find)
- Flume theory
- Flume ng configuration
- 2021 CCPC 哈尔滨 J. Local Minimum (思维题)
- [notes] take notes again -- learn by doing Verilog HDL – 014
- Jupyter服务安装及启动
- 文件包含漏洞
- La collection numérique Meng xiangshun, artiste national du tigre peint, est disponible en quantité limitée et est offerte avec Maotai de l'année du tigre
- 【Try to Hack】vulnhub narak
- 童年经典蓝精灵之百变蓝爸爸数字藏品中奖名单公布
猜你喜欢
Linux安装MySQL5
Configuration du Flume 4 - source personnalisée + sink
0/1分数规划专题
Withdrawal of user curve in qualified currency means loss
文件包含漏洞
ASP.Net Core创建Razor页面上传多个文件(缓冲方式)(续)
Tiger painter mengxiangshun's digital collection is on sale in limited quantities and comes with Maotai in the year of the tiger
.NetCore统一认证授权学习——第一次授权(2)
Foxit software was invited to appear at the 2022 advanced manufacturing digital intelligence development forum
ASP. Net core creates razor page and uploads multiple files (buffer mode) (Continued)
随机推荐
Introduction to the latest version 24.1.0.360 update of CorelDRAW
Flume ng configuration
Measures to support the development of advanced manufacturing industry in Futian District of Shenzhen in 2022
Finally, Amazon~
ETCD数据库源码分析——服务端PUT流程
4-1 port scanning technology
[boutique] detailed explanation of Pinia
Static static member variables use @value injection
mapbox-gl开发教程(十二):加载面图层数据
[USB flash disk test] in order to transfer the data at the bottom of the pressure box, I bought a 2T USB flash disk, and the test result is only 47g~
[buuctf.reverse] 142_[SUCTF2019]babyunic
Understanding of software test logic coverage
Freemaker template framework generates images
ASP. Net core creates razor page and uploads multiple files (buffer mode) (Continued)
苹果iPhone手机升级系统内存空间变小不够如何解决?
Dynamics crm: among locally deployed servers, sandbox, unzip, VSS, asynchronous and monitor services
Community interview -- jumpserver open source fortress in the eyes of an it newcomer
Koa 源码剖析
Startservice() procedure
Flume theory