This is a 玄学 exam

A.年轮蛋糕

最小的最大,二分首选

断环为链,check(x),x为答案,然后将每个大于x的子区间记录下来

如果有大于3个的话,那么x就可以是答案

那么·,在优化下来,二分里套个下二分,查长度右端点

时间复杂度:O(log(10^13)^3*n)

但是AC了

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
inline int read()
{
int f=,ans=;char c;
while(c<''||c>''){if(c=='-')f=-;c=getchar();}
while(c>=''&&c<=''){ans=ans*+c-'';c=getchar();}
return f*ans;
}
long long n,a[],s[],l,r,mid,maxn,inf=<<-;
long long cx(long long ll,long long rr,long long sc)
{
long long da=inf;
long long ls=ll,rs=rr,mid;
while(ls<=rs)
{
mid=(ls+rs)/;
if(s[mid]>=sc) da=min(da,mid),rs=mid-;
else ls=mid+;
}
return da;
}
bool check(long long xx)
{
for(long long i=;i<=n;i++)
{
long long qv=s[i-],ll=i,rr=i+n-,res=;
while(ll<=rr)
{
if(res==)
{
if(s[rr]-qv>=xx) return ;
else break;
}
long long as=cx(ll,rr,qv+xx);
if(as==inf)
{
if(res>=) return ;
else break;
}
qv=s[as];
ll=as+;
res++;
if(res==)
{
if(s[rr]-qv>=xx) return ;
else break;
}
if(res>=) return ;
}
}
return ;
}
int main()
{
n=read();
for(long long i=;i<=n;i++) a[i]=read(),a[i+n]=a[i],r+=a[i];
for(long long i=;i<=*n;i++) s[i]=s[i-]+a[i];
while(l<=r)
{
mid=(l+r)/;
if(check(mid)) maxn=max(maxn,mid),l=mid+;
else r=mid-;
}
printf("%lld",maxn);
}

B.最佳团体

link

玄学题目

复杂度未知,假装是A了吧

一看到一个和/一个和,分数规划的经典题

又想到若x可以作为答案的话,x之前也可以作为答案

所以可以二分

然后这个问题可以转化成在树上做背包即可

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
inline int read()
{
int f=,ans=;char c;
while(c<''||c>''){if(c=='-')f=-;c=getchar();}
while(c>=''&&c<=''){ans=ans*+c-'';c=getchar();}
return f*ans;
}
double eps=1e-;
struct node{
int u,v,nex;
}x[];
int cnt,n,head[],s[],t[];
double val[],dp[][];
double l,r,mid,maxn;
void add(int u,int v)
{
x[cnt].u=u,x[cnt].v=v,x[cnt].nex=head[u],head[u]=cnt++;
}
int m,size[],deep[];
void dfs(int f,int fath)
{
deep[f]=deep[fath]+;
size[f]=;
for(int i=head[f];i!=-;i=x[i].nex)
{
dfs(x[i].v,f);
size[f]+=size[x[i].v];
}
}
void dp_tree(int xx)
{
dp[xx][]=;int k=min(m,size[xx]);
for(int i=head[xx];i!=-;i=x[i].nex)
{
int v=x[i].v;
dp_tree(v);
for(int t=k;t>=;t--)
for(int j=min(t,size[v]);j>=;j--) dp[xx][t]=max(dp[xx][t],dp[xx][t-j]+dp[v][j]);
}
if(xx!=)
for(int t=k;t>=;t--) dp[xx][t]=dp[xx][t-]+val[xx];
}
bool check(double xx)
{
bool flag=false;
memset(dp,0xcf,sizeof(dp));
for(int i=;i<=n;i++)
val[i]=double(s[i]-xx*t[i]);
dp_tree();
return dp[][m]>=;
}
int main()
{
memset(head,-,sizeof(head));
m=read(),n=read();
for(int i=;i<=n;i++)
{
t[i]=read(),s[i]=read();
r+=double(s[i]);
int v=read();
add(v,i);
}
dfs(,);
l=,r*=;
while(l<=r)
{
double mid=(l+r)/;
if(check(mid)) l=mid+eps,maxn=max(maxn,mid);
else r=mid-eps;
}
printf("%.3lf",maxn);
}

C.起床困难综合症

link

一道思维题,二进制运算至于位有关,并没有与整体有关

所以就可以打一个表,0000000,1111111,位数都为30为(int的精度),然后与输入数据处理一下

看一下0可以转换成什么,1可以转换成什么

然后瞎搞一下即可

#include<iostream>
#include<cstdio>
#include<cstring>
#include<climits>
#include<algorithm>
using namespace std;
inline int read()
{
int f=,ans=;char c;
while(c<''||c>''){if(c=='-')f=-;c=getchar();}
while(c>=''&&c<=''){ans=ans*+c-'';c=getchar();}
return f*ans;
}
int n,m,l,r=INT_MAX,data,sry;
char str[];
int main()
{
n=read(),m=read();
for(int i=;i<=n;i++)
{
scanf("%s",str+);
if(str[]=='A') {int s=read();l&=s,r&=s;}
else if(str[]=='O') {int s=read();l|=s,r|=s;}
else
{int s=read();l^=s,r^=s;}
}
for(int i=;i>=;i--)
{
if(l&(<<i)) data|=(<<i);
else if(sry+(<<i)<=m)
if(r&(<<i)) data|=(<<i),sry+=(<<i);
}
cout<<data;
}
/*
3 10
AND 5
OR 6
XOR 7
*/

国庆 Day1的更多相关文章

  1. 正睿OI国庆day1

    正睿OI国庆day1 T1 \[ S_n=1*S_{n-1}+1*F_{n-1}+1*F_{n-2}+1*f_{n-1}+1*f_{n-2} \] \[ F_{n}=0*S_{n-1}+1*F_{n- ...

  2. 清北国庆day1 (脑)残

    (留坑) /* 不知道为什要找的循环节TM这么长 */ #include<cstdio> #include<cstdlib> #include<cstring> u ...

  3. 学大伟业 2017 国庆 Day1

    期望得分:100+100+20=220 实际得分:100+100+20=220 (好久没有期望==实际了 ,~\(≧▽≦)/~) 对于 a........a 如果 第1个a 后面出现的第1个b~z 是 ...

  4. 国庆集训 Day1 T2 生成图 DP

    国庆集训 Day1 T2 生成图 现在要生成一张\(n\)个点的有向图.要求满足: 1.若有 a->b的边,则有 b->a 的边 2.若有 a->b 的边和 b->c 的边,则 ...

  5. 牛客2018国庆集训 DAY1 D Love Live!(01字典树+启发式合并)

    牛客2018国庆集训 DAY1 D Love Live!(01字典树+启发式合并) 题意:给你一颗树,要求找出简单路径上最大权值为1~n每个边权对应的最大异或和 题解: 根据异或的性质我们可以得到 \ ...

  6. 湖南国庆模拟赛day1 分组

    题目大意:给你一个n个数的数列s,要对这些数进行分组,当有任意两个数在一种方案在一起而在另一种方案中不在一起算是两种不同的方案,一个组的"不和谐程度"为组内数的极差,如果只有一个人 ...

  7. 2017北京国庆刷题Day1 afternoon

    期望得分:100+100+100=300 实际得分:100+100+100=300 T1 一道图论好题(graph) Time Limit:1000ms   Memory Limit:128MB 题目 ...

  8. 牛客国庆训练,CCPC Camp DAY1 J 倍增,括号匹配

    https://www.nowcoder.com/acm/contest/201#question 题意:中文不翻译了 解法的个人理解: 对于一个合法的区间$[L,R]$ 1.显然其左括号的匹配位置都 ...

  9. 牛客国庆集训派对Day1.B.Attack on Titan(思路 最短路Dijkstra)

    题目链接 \(Description\) 给定\(n,m,C\)及大小为\((n+1)(m+1)\)的矩阵\(c[i][j]\).平面上有\((n+1)(m+1)\)个点,从\((0,0)\)编号到\ ...

随机推荐

  1. hdu2899Strange fuction(解方程+二分)

    Strange fuction Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  2. leetcode-分割回文子串

    给定一个字符串 s,将 s 分割成一些子串,使每个子串都是回文串. 返回 s 所有可能的分割方案. 示例: 输入: "aab" 输出: [ ["aa",&quo ...

  3. 利用nohup后台运行jar文件包程序

    Linux 运行jar包命令如下: 方式一: java -jar XXX.jar特点:当前ssh窗口被锁定,可按CTRL + C打断程序运行,或直接关闭窗口,程序退出 那如何让窗口不锁定? 方式二 j ...

  4. [Data Structures and Algorithms - 1] Introduction & Mathematics

    References: 1. Stanford University CS97SI by Jaehyun Park 2. Introduction to Algorithms 3. Kuangbin' ...

  5. LeetCode - 268. Missing Number - stable_sort应用实例 - ( C++ ) - 解题报告

    1.题目大意 Given an array nums, write a function to move all 0's to the end of it while maintaining the ...

  6. zookeeper:一.zookeeper集群安装

    1.zookeeper简介2.安装zookeeper2.1 安装环境准备2.2 安装zookeeper2.2.1.解压zookeeper压缩包到/opt/zookeeper2.2.2.编辑zookee ...

  7. LVS+Keepalive+Nginx实现负载均衡

    本文参考:http://blog.csdn.net/yinwenjie/article/details/47211551 简单粗暴写一下,做备忘,刚刚搭好没做优化呢,后期补充 一.机器准备 LVS-M ...

  8. C语言文件基本操作

    1.用文本方式储存‘1’,‘0’,‘2’存入文件,然后用二进制方式从文件开头读出一个short型数据,并验证结果是否正确 #include<stdio.h> #include<str ...

  9. C语言中动态内存的分配(malloc,realloc)

    动态内存分配:根据需要随时开辟,随时释放的内存分配方式.分配时机和释放时机完全由程序员决定,由于没有数据声明,这部分空间没有名字.无法像使用变量或数组那样通过变量名或数组名引用其中的数据,只能通过指针 ...

  10. Lake Counting(DFS连通图)

    Description Due to recent rains, water has pooled in various places in Farmer John's field, which is ...