zoukankan      html  css  js  c++  java
  • P7076 [CSP-S2020] 动物园

    Archie

    当年咋就不加ull呢

    很简单,按照二进制位拆就行了

    /*
    �Һܱ�Ǹ 
    */
    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<map>
    #include<stack>
    #include<queue>
    #include<vector>
    #define ll unsigned long long
    #define int unsigned long long
    using namespace std;
    int read(){
    	int ans=0,f=1;
    	char c;
    	c=getchar();
    	while(c!='-'&&(c<'0'||c>'9')){
    		c=getchar();
    	}
    	if(c=='-'){
    		f=-1;
    		c='0';
    	}
    	while(c>='0'&&c<='9'){
    		ans=(ans<<1)+(ans<<3)+c-'0';
    		c=getchar();
    	}
    	return ans*f;
    }
    struct b{
    	int to;
    	int ne;
    }e[1000006];
    int head[1000009];
    int n,m,c,k;
    int food[1000009];
    int ai[1000009];
    int Ar;
    map<int ,int > ab;
    int vis[66];
    void chai(int now){
    	int p=0;
    	while(now){
    		if(now%2==1&&(!vis[p])){
    				vis[p]=1;
    			for(int i=head[p];i;i=e[i].ne){
    				ab[e[i].to]=1;
    			}
    		}
    		now>>=1;
    		p++;
    	}
    	return ;
    }
    int x,y;
    int p;
    void add(int f,int to){
    	p++;
    	e[p].to=to;
    	e[p].ne=head[f];
    	head[f]=p;
    	return ;
    }
    void find(){
        ll cnt=0;
    	ll ans=1;
    	for(int i=0;i<k;++i){
    		int f=1;
    		for(int j=head[i];j;j=e[j].ne){
    			if(!ab[e[j].to]){
    				f=0;
    				break;
    			}
    		}
    		if(f){
            cnt++;
    			ans*=(ll)2;
    		}
    	}
        if(cnt==64&&!n){
        puts("18446744073709551616");
        return ;
        }	
        if(ans==1){
    		cout<<0;
    	}else
    	cout<<(ll)ans-n;
    	return ;
    }
    signed main(){
    //	freopen("zoo.in","r",stdin);
    //	freopen("zoo.out","w",stdout);
    	n=read();
    	m=read();
    	c=read();
    	k=read();
    	for(int i=1;i<=n;++i){
    		ai[i]=read();
    	}
    	for(int i=1;i<=m;++i){
    		x=read();
    		y=read();
    		add(x,y);
    	}
    	for(int i=1;i<=n;++i){
    		chai(ai[i]);
    	}
    	find();
    	return 0;
    }
    
  • 相关阅读:
    个人项目1修改版——自动生成四则表达式
    个人项目1——自动生成四则运算
    《面向对象分析与设计》阅读笔记3
    《面向对象分析与设计》阅读笔记2
    《面向对象分析与设计》阅读笔记1
    《梦断代码》阅读笔记3
    《梦断代码》阅读笔记2
    MVC中的过滤器
    MVC中的区域
    MVC中的路由
  • 原文地址:https://www.cnblogs.com/For-Miku/p/15033131.html
Copyright © 2011-2022 走看看