• 【NOIp2019模拟】题解


    T1

    傻逼题,速度的函数是收敛的,一个等比数列求和就完了

    #include<bits/stdc++.h>
    using namespace std;
    const int RLEN=1<<20|1;
    inline char gc(){
    	static char ibuf[RLEN],*ib,*ob;
    	(ib==ob)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
    	return (ib==ob)?EOF:*ib++;
    }
    #define gc getchar
    inline int read(){
    	char ch=gc();
    	int res=0,f=1;
    	while(!isdigit(ch))f^=ch=='-',ch=gc();
    	while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
    	return f?res:-res;
    }
    #define pb push_back
    #define re register
    #define ll long long
    #define pii pair<int,int>
    #define fi first
    #define se second
    #define cs const
    cs double pi=acos(-1);
    double thi,v,d,g,vx,vy,t;
    int main(){
    	int T=read();
    	while(T--){
    		scanf("%lf%lf%lf%lf",&thi,&v,&d,&g);
    		thi=thi/180.0;
    		vx=v*cos(pi*thi),vy=v*sin(pi*thi);
    		t=vy/(1.0-d*d),t/=g,t=t*2;
    		printf("%.5lf
    ",t*vx);
    	}
    }
    
    

    T2:

    水题

    考虑说可以发现我们要把所有奇数拿出来
    考虑说一个数不断乘22nn有几个数
    如果是偶数个就给22个集合相同的贡献
    奇数个就会有一个集合多11

    最后要2个集合分别是mmnmn-m
    选数的方案就是一个组合数

    用卢卡斯定理做一下就完了

    结果无解的情况少判了一个为负
    挂成20pts20pts

    #include<bits/stdc++.h>
    using namespace std;
    const int RLEN=1<<20|1;
    inline char gc(){
    	static char ibuf[RLEN],*ib,*ob;
    	(ib==ob)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
    	return (ib==ob)?EOF:*ib++;
    }
    #define int long long
    #define gc getchar
    inline int read(){
    	char ch=gc();
    	int res=0,f=1;
    	while(!isdigit(ch))f^=ch=='-',ch=gc();
    	while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
    	return f?res:-res;
    }
    #define pb push_back
    #define re register
    #define ll long long
    #define pii pair<int,int>
    #define fi first
    #define se second
    #define cs const
    cs int mod=10000019;
    inline int add(int a,int b){return (a+=b)>=mod?a-mod:a;}
    inline void Add(int &a,int b){(a+=b)>=mod?a-=mod:0;}
    inline int dec(int a,int b){return (a-=b)<0?a+mod:a;}
    inline void Dec(int &a,int b){(a-=b)<0?a+=mod:0;}
    inline int mul(int a,int b){return 1ll*a*b>=mod?1ll*a*b%mod:a*b;}
    inline void Mul(int &a,int b){a=1ll*a*b>=mod?1ll*a*b%mod:a*b;}
    inline int ksm(int a,int b,int res=1){for(;b;b>>=1,Mul(a,a))(b&1)&&(res=mul(res,a));return res;}
    int fac[mod+100],ifac[mod+100];
    int n,q,m;
    inline void init(){
    	fac[0]=ifac[0]=1;
    	for(int i=1;i<mod;i++)fac[i]=mul(fac[i-1],i);
    	ifac[mod-1]=ksm(fac[mod-1],mod-2);
    	for(int i=mod-2;i;i--)ifac[i]=mul(ifac[i+1],i+1);
    }
    inline int C(int n,int m){
    	return n<m?0:mul(fac[n],mul(ifac[m],ifac[n-m]));
    }
    inline int Lucas(int n,int m){
    	if(n<m)return 0;
    	if(n<mod&&m<mod)return C(n,m);
    	return mul(Lucas(n/mod,m/mod),C(n%mod,m%mod));
    }
    int sip,plx;
    inline int howmany(int l,int r){
    	int del=r-l+1;
    	if(del&1)return (del/2)+((l&1)==1);
    	return del/2;
    }
    inline void divid(int x){
    	int r=x,l,cur=1;
    	while(r){
    		l=r/2+1;
    		if(cur)sip+=howmany(l,r);
    		else plx+=howmany(l,r);
    		r=l-1,cur^=1;
    	}
    }
    signed main(){
    	init();
    	n=read(),q=read();
    	divid(n);
    	int bas=ksm(2,plx);
    	while(q--){
    		m=read();
    		int del=sip+m+m-n;
    		if(del&1){cout<<0<<'
    ';continue;}
    		if(del<0){cout<<0<<'
    ';continue;} 
    		del/=2;
    		cout<<mul(bas,Lucas(sip,del))<<'
    ';
    	}
    }
    
    

    T3:

    傻逼题
    和二分图差不多,对于连断每次乘逆元就可以了

    #include<bits/stdc++.h>
    using namespace std;
    const int RLEN=1<<20|1;
    inline char gc(){
    	static char ibuf[RLEN],*ib,*ob;
    	(ib==ob)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
    	return (ib==ob)?EOF:*ib++;
    }
    #define gc getchar
    inline int read(){
    	char ch=gc();
    	int res=0,f=1;
    	while(!isdigit(ch))f^=ch=='-',ch=gc();
    	while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
    	return f?res:-res;
    }
    #define pb push_back
    #define re register
    #define ll long long
    #define pii pair<int,int>
    #define fi first
    #define se second
    #define cs const
    cs int mod=1e9+7;
    inline int add(int a,int b){return (a+=b)>=mod?a-mod:a;}
    inline void Add(int &a,int b){(a+=b)>=mod?a-=mod:0;}
    inline int dec(int a,int b){return (a-=b)<0?a+mod:a;}
    inline void Dec(int &a,int b){(a-=b)<0?a+=mod:0;}
    inline int mul(int a,int b){return 1ll*a*b>=mod?1ll*a*b%mod:a*b;}
    inline void Mul(int &a,int b){a=1ll*a*b>=mod?1ll*a*b%mod:a*b;}
    inline int ksm(int a,int b,int res=1){for(;b;b>>=1,Mul(a,a))(b&1)&&(res=mul(res,a));return res;}
    cs int N=100005;
    int n,m,ans;
    int inv[N],anc[N];
    inline void init(){
    	inv[0]=inv[1]=1;
    	for(int i=2;i<=n;i++)inv[i]=mul(mod-mod/i,inv[mod%i]);
    }
    namespace Set{
    	int fa[N],siz[N],top;
    	pii stk[N];
    	inline void init(){
    		for(int i=1;i<=n;i++)fa[i]=i,siz[i]=1;
    	}
    	inline int find(int x){
    		return fa[x]==x?x:find(fa[x]);
    	}
    	inline void merge(int u,int v){
    		int f1=find(u),f2=find(v);
    		if(f1!=f2){
    			if(siz[f1]>siz[f2])swap(f1,f2);
    			Mul(ans,inv[siz[f1]]),Mul(ans,inv[siz[f2]]);
    			fa[f1]=f2,siz[f2]+=siz[f1];
    			Mul(ans,siz[f2]);
    			stk[++top]=pii(f1,f2);
    		}
    	}
    	inline void getback(int pre){
    		static int u,v;
    		while(top>pre){
    			u=stk[top].fi,v=stk[top].se;
    			Mul(ans,inv[siz[v]]);
    			fa[u]=u,siz[v]-=siz[u];
    			Mul(ans,siz[u]),Mul(ans,siz[v]);
    			top--;
    		}
    	}
    }
    map<pii,int> tt;
    vector<pii> e[N<<2];
    #define lc (u<<1)
    #define rc ((u<<1)|1)
    #define mid ((l+r)>>1)
    void update(int u,int l,int r,int st,int des,pii k){
    	if(st<=l&&r<=des){e[u].pb(k);return;}
    	if(st<=mid)update(lc,l,mid,st,des,k);
    	if(mid<des)update(rc,mid+1,r,st,des,k);
    }
    void dfs(int u,int l,int r){
    	int pre=Set::top;
    	for(int i=0;i<e[u].size();i++){
    		pii x=e[u][i];
    		Set::merge(x.fi,x.se);
    	}
    	if(l==r){anc[l]=ans;}
    	else dfs(lc,l,mid),dfs(rc,mid+1,r);
    	Set::getback(pre);
    }
    vector<pii> E;
    int main(){
    	n=read(),m=read();
    	Set::init();
    	init(),ans=1;
    	for(int i=1;i<=m;i++){
    		int op=read();
    		if(op==1){
    			int u=read(),v=read();
    			if(u>v)swap(u,v);
    			tt[pii(u,v)]=i;
    			E.pb(pii(u,v));
    		}
    		else{
    			int u=read(),v=read();
    			if(u>v)swap(u,v);
    			update(1,1,m,tt[pii(u,v)],i-1,pii(u,v));
    			tt.erase(pii(u,v));
    		}
    	}
    	for(int i=0;i<E.size();i++){
    		pii x=E[i];
    		if(tt.count(x))update(1,1,m,tt[x],m,x),tt.erase(x);
    	}
    	dfs(1,1,m);
    	for(int i=1;i<=m;i++)cout<<anc[i]<<"
    ";
    }
    
    
  • 相关阅读:
    被老板批评“公司离开谁都照转,谁的工作干不好谁走人”,你会立马辞职吗?
    开课啦 dubbo-go 微服务升级实战
    如何通过 Serverless 提高 Java 微服务治理效率?
    Alluxio 助力 Kubernetes,加速云端深度学习
    收藏!这些 IDE 使用技巧,你都知道吗
    基于 Wasm 和 ORAS 简化扩展服务网格功能
    基于 KubeVela 与 Kubernetes 打造“无限能力”的开放 PaaS
    Kubernetes 稳定性保障手册 -- 日志专题
    Kubernetes 稳定性保障手册 -- 极简版
    Serverless 如何在阿里巴巴实现规模化落地?
  • 原文地址:https://www.cnblogs.com/stargazer-cyk/p/12328631.html
Copyright © 2020-2023  润新知