• 2016 ICPC 沈阳


    A - Thickest Burger

    a+b+max(a,b)

    #include <bits/stdc++.h>
    
    using namespace std;
    typedef long long ll;
    
    int main(){
    	//freopen("in.txt","r",stdin);
    	int n,a,b;
    	while(~scanf("%d",&n)){
    		for(int i=1;i<=n;i++){
    			scanf("%d%d",&a,&b);
    			printf("%d
    ",a+b+max(a,b));
    		}
    	}
    	return 0;
    }
    

    B - Relative atomic mass

    #include <bits/stdc++.h>
    
    using namespace std;
    typedef long long ll;
    char s[100];
    int main(){
    	//freopen("in.txt","r",stdin);
    	int t;
    	scanf("%d",&t);
    	while(t--){
    		scanf("%s",s);
    		int ans=0;
    		int len=strlen(s);
    		for(int i=0;i<len;i++) {
    			if(s[i]=='H') ans+=1;
    			else if(s[i]=='O') ans+=16;
    			else ans+=12;
    		}
    		printf("%d
    ",ans);
    	}
    	return 0;
    }
    

    C - Recursive sequence

    将$n4$,$n{3,2,1,0}$带着一起转移。

    #include <bits/stdc++.h>
    
    using namespace std;
    typedef long long ll;
    const ll P = 2147493647;
    const int N = 7;
    ll n,a,b;
    struct matrix {
    	ll a[N][N];
    	int row,col;
    	matrix():row(N),col(N){memset(a,0,sizeof a);}
    	ll* operator [](int x){return a[x];}
    	matrix operator * (matrix x){
    		matrix tmp;
    		for(int i=0;i<N;i++)
    			for(int j=0;j<N;j++){
    				tmp[i][j]=0;
    				for(int k=0;k<N;k++)
    					tmp[i][j]=(tmp[i][j]+a[i][k]*x[k][j]%P)%P;
    			}
    		return tmp;
    	}
    	void operator *= (matrix x){*this = *this * x;}
    
    	matrix operator ^ (ll x){
    		matrix ret;
    		for(int i=0;i<N;i++) ret[i][i]=1;
    		matrix tmp=*this;
    		for(;x;x>>=1,tmp*=tmp){if(x&1)ret *= tmp;}
    		return ret;
    	}
    };
    
    
    
    int main(){
    	//freopen("in.txt","r",stdin);
    	int T;
    	cin>>T;
    	while(T--){
    		cin>>n>>a>>b;
    		a%=P;b%=P;
    		if(n==1){
    			printf("%lld
    ",a);
    			continue;
    		}
    		if(n==2){
    			printf("%lld
    ",b);
    			continue;
    		}
    		matrix base;
    		base[0][1]=2;
    		base[0][0]=base[0][2]=base[1][0]=1;
    		base[2][2]=base[3][3]=base[4][4]=base[5][5]=base[6][6]=1;
    		base[2][6]=base[3][6]=base[4][6]=base[5][6]=1;
    		base[2][3]=4;base[2][4]=6;base[2][5]=4;
    		base[3][4]=base[3][5]=3;
    		base[4][5]=2;
    		base=base^(n-2);
    		ll res = base[0][0]*b%P+base[0][1]*a%P+81ll*base[0][2]%P+27ll*base[0][3]%P+9ll*base[0][4]%P+3ll*base[0][5]%P+base[0][6];
    		res %= P;
    		cout<<res<<endl;
    	}
    	return 0;
    }
    

    E - Counting Cliques

    #include<iostream>
    #include<string.h>
    #include<vector>
    using namespace std;
    int s,u,v,ans;
    int g[111][111];
    int data[111];
    vector<int>e[1111];
    int dfs(int id,int size)
    {
    	if(size==s)
    	{
    		ans++;
    		return 0;
    	}
    	for(int i=0;i<e[id].size();i++)
    	{
    		int ep=e[id][i];
    		bool flag=true;
    		for(int j=1;j<size;j++)
    			if(!g[ep][data[j]])
    			{
    				flag=false;
    				break;
    			}
    		if(flag)
    		{
    			data[++size]=ep;
    			dfs(ep,size);
    			data[size--]=0;
    		}
    	}
    }
    int main()
    {
    	int t;
    	cin>>t;
    	while(t--)
    	{
    		int n,m;
    		cin>>n>>m>>s;
    		memset(g,0,sizeof(g));
    		for(int i=1;i<=n;i++)
    			e[i].clear();
    		for(int i=1;i<=m;i++)
    		{
    			cin>>u>>v;
    			if(u>v)
    				swap(u,v);
    			e[u].push_back(v);
    			g[u][v]=g[v][u]=1;
    		}
    		ans=0;
    		for(int i=1;i<=n;i++)
    		{
    			int size=1;
    			data[1]=i;
    			dfs(i,1);
    		}
    		cout<<ans<<endl;
    	}
        return 0;
    }
    

    G - Do not pour out

    积分+二分答案。

    #include <bits/stdc++.h>
    
    using namespace std;
    typedef long long ll;
    const double eps = 1e-10;
    const double pi = 4.0*atan(1.0);
    
    int dcmp(double x){
    	if(x<-eps) return -1;
    	if(x>eps) return 1;
    	return 0;
    }
    
    double d;
    
    double calc(double x){
    	return pi*cos(x)-x*cos(x)+sin(x)-1.0/3.0*sin(x)*sin(x)*sin(x);
    }
    
    double f(double x){
    	double ax=acos(2.0*tan(x)-1.0);
    	double ret=calc(ax)-calc(pi);
    	return ret/tan(x);
    }
    
    int main(){
    	//freopen("in.txt","r",stdin);
    	int T;
    	cin>>T;
    	while(T--){
    		scanf("%lf",&d);
    		if(dcmp(d)<=0){
    			puts("0.00000");
    			continue;
    		}
    		if(dcmp(d-1)>=0){
    			double theta=atan(2-d);
    			double res=pi/cos(theta);
    			printf("%.5lf
    ",res);
    		} else {
    			double l=0.0,r=pi/4.0,ansk;
    			while(dcmp(l-r)<=0){
    				double mid = (l+r)/2.0;
    				double sx=f(mid);
    				if(dcmp(sx-d*pi)<=0){
    					l=mid+eps;
    					ansk=mid;
    				} else {
    					r=mid-eps;
    				}
    			}
    			double ax=acos(2.0*tan(ansk)-1.0-eps);
    			double sx=pi-ax+sin(ax)*cos(ax);
    			double res=sx/sin(ansk);
    			printf("%.5lf
    ",res);
    		}
    	}
    	return 0;
    }
    

    H - Guessing the Dice Roll

    建立AC自动机fail节点接建立方程组,高斯消元。
    坑。

  • 相关阅读:
    取出session中的所有属性与值的方法
    jqGrid几个需要注意的默认设置
    java语言中除数为零问题
    java语言中Object转为String的几种形式
    highCharts提示框不显示的问题
    jqGrid使用setColProp方法动态改变列属性
    jgGrid中的editrules使用函数来进行验证
    大坝安全监测系统预警值上下限设定
    谓词 (NSPredicate)使用详情
    kvc(键-值编码)
  • 原文地址:https://www.cnblogs.com/foreignbill/p/7875927.html
Copyright © 2020-2023  润新知