FallDream打的AB都FFT了,只剩一个我打的C,没进前一百,之后看看马拉松复活赛有没机会呗。

A. Voltage Keepsake

题目大意:n个东西,每个东西一开始有bi能源,每秒消耗ai能源,每秒可以给一个东西加p能源,秒可以为实数,问至多多少秒内所有东西能源一直为正。(n<=100,000)

思路:二分答案,随便check一下。不特判无解可能会炸精度。

#include<cstdio>
#include<algorithm>
using namespace std;
#define lb long double
inline int read()
{
int x;char c;
while((c=getchar())<''||c>'');
for(x=c-'';(c=getchar())>=''&&c<='';)x=x*+c-'';
return x;
}
#define MN 100000
int a[MN+],b[MN+];
int main()
{
int n=read(),p=read(),t,i;long long cnt=;
lb l,r,mid,sum;
for(i=;i<=n;++i)cnt+=a[i]=read(),b[i]=read();
if(cnt<=p)return *puts("-1");
for(t=,l=,r=1e12;--t;)
{
mid=(l+r)/;
for(i=,sum=;i<=n;++i)sum+=max((lb),a[i]*mid-b[i]);
(sum>p*mid?r:l)=mid;
}
printf("%.10lf",(double)l);
}

B. Volatile Kite

题目大意:给出一个n的点的凸多边形,求一个最大的d,使得每个点任意移动d以内的距离,得到的新多边形边不相撞且仍是凸多边形。(n<=1,000)

思路:枚举相邻三个点,d不会超过点i+1到点i与点i+2连线距离的一半,复杂度O(n)。

#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
inline int read()
{
int x,f=;char c;
while((c=getchar())<''||c>'')if(c=='-')f=;
for(x=c-'';(c=getchar())>=''&&c<='';)x=x*+c-'';
return f?x:-x;
}
#define MN 1000
struct point{double x,y;}p[MN+];
double dis(point a){return sqrt(a.x*a.x+a.y*a.y);}
point operator-(point a,point b){return (point){a.x-b.x,a.y-b.y};}
double operator*(point a,point b){return a.x*b.y-a.y*b.x;}
int main()
{
int n=read(),i,j;double ans=1e18;
for(i=;i<n;++i)p[i].x=read(),p[i].y=read();
p[n]=p[];p[n+]=p[];
for(i=;i<n;++i)ans=min(ans,fabs((p[i+]-p[i])*(p[i+]-p[i]))/dis(p[i]-p[i+]));
printf("%.10lf",ans/);
}

C. Vulnerable Kerbals

题目大意:给出m和n个0~m-1内的数,构造一个尽可能长的所有元素都在0~m-1内的数列,使所有前缀积模m不相同且不在n个数中出现过。(0<=n<m<=200,000)

思路:若前i个数的前缀积为x,前i+1个数的前缀积可以为y当且仅当ax-bm=y有解,即gcd(x,m)|y,若我们让所有满足这个条件的x,y,x向y连边,题目即求最长链,gcd(x,m)相同的x在一个连通块内,每个连通块gcd(xi,m)向连通块gcd(xj,m)(gcd(xi,m)|gcd(xj,m))连边,得到一个边数为O(nlogn)的拓扑图,直接DP即可。

#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
#define ll long long
char B[<<],*S=B,C;int X;
inline int read()
{
while((C=*S++)<''||C>'');
for(X=C-'';(C=*S++)>=''&&C<='';)X=(X<<)+(X<<)+C-'';
return X;
}
#define MN 200000
int gcd(int x,int y){return y?gcd(y,x%y):x;}
vector<int> v[MN+];
int m,u[MN+],f[MN+],r[MN+],ls=;
void exgcd(ll x,ll y,ll z,ll&a,ll&b)
{
if(!y){a=z/x;b=;return;}
ll aa,bb;exgcd(y,x%y,z,aa,bb);
a=-bb;b=-aa-bb*(x/y);
}
void out(int x)
{
if(!x)return;
out(r[x]);
int i;ll a,b;
for(i=;i<v[x].size();++i)
exgcd(ls,m,v[x][i],a,b),
printf("%d ",(a%m+m)%m),ls=v[x][i];
}
int main()
{
fread(B,,<<,stdin);
int n,i,j,mx=;
n=read();m=read();
for(i=;i<=n;++i)u[read()]=;
for(i=;i<m;++i)if(!u[i])v[gcd(i,m)].push_back(i);
for(i=;i<m;++i)
{
if((f[i]+=v[i].size())>f[mx])mx=i;
for(j=i;j<m;j+=i)if(f[i]>f[j])f[j]=f[i],r[j]=i;
}
printf("%d\n",f[mx]+!u[]);
out(mx);
if(!u[])puts("");
}

D. Varying Kibibits

题目大意:给出n个数的集合T,F(S)的各位数字为集合S中各个数字对应位数字的最小值,例如F(123,321)=121,求的异或和。(n<=10^6,数字<=999,999)

思路:F值恰好为x的子集不好求,我们考虑求出F值各位数字都大等x的子集,也就是数字各位都大等于x的数的集合的所有子集,答案我们枚举各位加一,容斥一下即可求出,现在问题是如何求出这个集合的子集和的平方和,只要同时维护一个集合的子集和的和、子集和的平方和、集合大小,就可以支持合并集合和删除集合(稍微推一下式子,挺简单的,或者看下面的代码),数字各位都大等于x的集合同样也可以容斥求出,总复杂度O(2^6*n),可能需要卡卡常数,正解貌似是O(6n)的,以后补。

#include<cstdio>
char B[<<],*S=B,C;int X;
inline int read()
{
while((C=*S++)<''||C>'');
for(X=C-'';(C=*S++)>=''&&C<='';)X=X*+C-'';
return X;
}
#define MN 1000000
#define MOD 1000000007
int a[MN+],p2[MN+],r2[MN+],pw[];
struct data
{
int s1,s2,sz;
data(int s1=,int s2=,int sz=):s1(s1),s2(s2),sz(sz){}
void operator+=(const data&b)
{
s2=(1LL*s2*p2[b.sz]+1LL*b.s2*p2[sz]+2LL*s1*b.s1)%MOD;
s1=(1LL*s1*p2[b.sz]+1LL*b.s1*p2[sz])%MOD;
sz+=b.sz;
}
void operator-=(const data&b)
{
sz-=b.sz;
s1=((s1-1LL*b.s1*p2[sz])%MOD+MOD)*r2[b.sz]%MOD;
s2=((s2-2LL*s1*b.s1-1LL*b.s2*p2[sz])%MOD+MOD)*r2[b.sz]%MOD;
}
}s[MN+];
void solve1(int x,int k,int d,int p)
{
if(d>){if(x!=k)if(p>)s[x]+=s[k];else s[x]-=s[k];return;}
solve1(x,k,d+,p);
if(k%pw[d+]/pw[d]<)solve1(x,k+pw[d],d+,-p);
}
inline int mod(int x){if(x>=MOD)x-=MOD;if(x<)x+=MOD;return x;}
void solve2(int x,int k,int d,int p)
{
if(d>){if(x!=k)s[x].s2=mod(s[x].s2+p*s[k].s2);return;}
solve2(x,k,d+,p);
if(k%pw[d+]/pw[d]<)solve2(x,k+pw[d],d+,-p);
}
int main()
{
B[fread(B,,<<,stdin)]=;
int n=read(),i;long long ans=;
while(n--)++a[read()];
for(p2[]=i=;i<=MN;++i)p2[i]=(p2[i-]<<)%MOD;
for(r2[]=i=;i<=MN;++i)r2[i]=(r2[i-]*((MOD+1LL)>>))%MOD;
for(pw[]=i=;i<;++i)pw[i]=pw[i-]*;
for(i=MN;i--;){solve1(i,i,,-);while(a[i]--)s[i]+=data(i,1LL*i*i%MOD,);}
for(i=;i<MN;++i)solve2(i,i,,),ans^=1LL*i*s[i].s2;
printf("%I64d",ans);
}

VK Cup 2017 - Round 2的更多相关文章

  1. Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) 菜鸡只会ABC!

    Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) 全场题解 菜鸡只会A+B+C,呈上题解: A. Bear and ...

  2. Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3)(A.B.C,3道暴力题,C可二分求解)

    A. Is it rated? time limit per test:2 seconds memory limit per test:256 megabytes input:standard inp ...

  3. Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) A B C D 水 模拟 二分 贪心

    A. Is it rated? time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

  4. Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2)(A.思维题,B.思维题)

    A. Vicious Keyboard time limit per test:2 seconds memory limit per test:256 megabytes input:standard ...

  5. VK Cup 2017 - Round 1

    和FallDream组队瞎打一通--B两个人写的都挂了233,最后只剩下FallDream写的A和我写的C,最后我yy了个E靠谱做法结果打挂了,结束之后改了改就A了,难受. AC:AC Rank:18 ...

  6. Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) 题解【ABCDE】

    A. Vicious Keyboard 题意:给你一个字符串,里面只会包含VK,这两种字符,然后你可以改变一个字符,你要求VK这个字串出现的次数最多. 题解:数据范围很小,暴力枚举改变哪个字符,然后c ...

  7. Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) A B C D 暴力 水 二分 几何

    A. Vicious Keyboard time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  8. Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) D - Dynamic Problem Scoring

    地址:http://codeforces.com/contest/807/problem/D 题目: D. Dynamic Problem Scoring time limit per test 2 ...

  9. Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) E

    Description Bear Limak prepares problems for a programming competition. Of course, it would be unpro ...

  10. VK Cup 2017 - Round 1 (CDE)

    771C Bear and Tree Jumps 大意: 给定树,每步能走到距离不超过$k$的任意点,记$f(s,t)$为$s$到$t$的最少步数,求$\sum\limits_{s<t}f(s, ...

随机推荐

  1. 基于Python的Web应用开发实践总结

    基于Python的Web应用开发学习总结 项目地址   本次学习采用的是Flask框架.根据教程开发个人博客系统.博客界面如图所示. 整个学习过程收获很多,以下是学习总结. 1.virtualenv ...

  2. 和为S的连续正数序列——牛客网(剑指offer)

    题目描述 小明很喜欢数学,有一天他在做数学作业时,要求计算出9~16的和,他马上就写出了正确答案是100.但是他并不满足于此,他在想究竟有多少种连续的正数序列的和为100(至少包括两个数).没多久,他 ...

  3. 从0开始的LeetCode生活—461-Hamming Distance(汉明距离)

    题目: The Hamming distance between two integers is the number of positions at which the corresponding ...

  4. phalcon环境的搭建和dll扩展下载与选择

    phalcon需要下载一个扩展的dll文件才能运行项目 其中需要注意dll放在一个php扩展目录中windows下php/ext/,还需要在两个Php.ini文件中增加扩展说明,一般只需要更改 D:\ ...

  5. 区间的连续段~ST表(模板题)

    链接:https://www.nowcoder.com/acm/contest/82/B来源:牛客网 时间限制:C/C++ 7秒,其他语言14秒 空间限制:C/C++ 262144K,其他语言5242 ...

  6. Spring源码情操陶冶#task:scheduled-tasks解析器

    承接前文Spring源码情操陶冶#task:executor解析器,在前文基础上解析我们常用的spring中的定时任务的节点配置.备注:此文建立在spring的4.2.3.RELEASE版本 附例 S ...

  7. vue-cli项目中,全局引入jquery

    命令行执行 npm install --save jquery 找到webpack.base.conf.js文件,写入代码: const webpack = require('webpack') 在m ...

  8. maven常见问题处理(3-2)maven打包时跳过测试的几个方法

    运行mvn install时跳过Test方法一:<project> [...] <build> <plugins> <plugin> <group ...

  9. leetcode算法:Trim a Binar Search Tree

    Given a binary search tree and the lowest and highest boundaries as L and R, trim the tree so that a ...

  10. python——函数

    python--函数 1.介绍: 在过去的十年间,大家广为熟知的编程方法无非两种:面向对象和面向过程,其实,无论哪种,都是一种编程的规范或者是如何编程的方法论.而如今,一种更为古老的编程方式:函数式编 ...