zoukankan      html  css  js  c++  java
  • LuoguP5390 [Cnoi2019]数学作业(数论)

    转进制,然后发现贡献只有(1_{(2)}),取奇数个的子集方案是(2^{n-1})

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <cstdlib>
    #include <algorithm>
    #include <cmath>
    #define R(a,b,c) for(register int a = (b); a <= (c); ++a)
    #define nR(a,b,c) for(register int a = (b); a >= (c); --a)
    #define Fill(a,b) memset(a, b, sizeof(a))
    #define Swap(a,b) ((a) ^= (b) ^= (a) ^= (b))
    #define QWQ
    #ifdef QWQ
    #define D_e_Line printf("
    ---------------
    ")
    #define D_e(x) cout << (#x) << " : " << x << "
    "
    #define Pause() system("pause")
    #define FileOpen() freopen("in.txt", "r", stdin)
    #define FileSave() freopen("out.txt", "w", stdout)
    #define TIME() fprintf(stderr, "
    TIME : %.3lfms
    ", clock() * 1000.0 / CLOCKS_PER_SEC)
    #else
    #define D_e_Line ;
    #define D_e(x) ;
    #define Pause() ;
    #define FileOpen() ;
    #define FileSave() ;
    #define TIME() ;
    #endif
    struct ios {
    	template<typename ATP> inline ios& operator >> (ATP &x) {
    		x = 0; int f = 1; char c;
    		for(c = getchar(); c < '0' || c > '9'; c = getchar()) if(c == '-') f = -1;
    		while(c >= '0' && c <='9') x = x * 10 + (c ^ '0'), c = getchar();
    		x *= f;
    		return *this;
    	}
    }io;
    using namespace std;
    template<typename ATP> inline ATP Max(ATP a, ATP b) {
    	return a > b ? a : b;
    }
    template<typename ATP> inline ATP Min(ATP a, ATP b) {
    	return a < b ? a : b;
    }
    template<typename ATP> inline ATP Abs(ATP a) {
    	return a < 0 ? -a : a;
    }
    
    const int mod = 998244353;
    
    long long mul(long long a, long long b) {
        long long l = a * (b >> 25ll) % mod * (1ll << 25) % mod;
        long long r = a * (b & ((1ll << 25) - 1)) % mod;
        return (l + r) % mod;
    }
    inline long long Pow(int a, long long b) {
    	long long s = 1;
    	while(b){
    		if(b & 1) s = mul(s, a);//s * a % mod;
    		a = mul(a, a), b >>= 1;//a = a * a % mod, b >>= 1;
    	}
    	return s;
    }
    int main() {
    	int Tasks;
    	io >> Tasks;
    	while(Tasks--){
    		int n;
    		io >> n;
    		long long ans = 0;
    		R(i,1,n){
    			int x;
    			io >> x;
    			ans |= x;
    		}
    		printf("%lld
    ", ans * Pow(2, n - 1) % mod);
    	
    	}
    	return 0;
    }
    

  • 相关阅读:
    最短路径—Dijkstra算法和Floyd算法
    设计模式之工厂模式(Factory模式)
    接口继承与实现继承
    设计模式之工厂模式
    C++的四种强制转型形式:
    手写atoi、strcpy、strcat
    进程和线程关系及区别
    海量数据处理
    什么是死锁,简述死锁发生的四个必要条件,如何避免与预防死锁
    kolla-ansible 重新部署 ceph 遇到的问题
  • 原文地址:https://www.cnblogs.com/bingoyes/p/11747142.html
Copyright © 2011-2022 走看看