• 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;
    }
    

  • 相关阅读:
    优秀的 Java 项目,代码都是如何分层的?
    计算机应届生月薪大多是多少?
    零基础要怎么学JAVA?
    自学 Java 怎么入门?
    Java学习路线总结,已Get腾讯Offer
    java培训出来的如何找工作?
    离散数学学习笔记
    一些公式
    一个模拟
    秦皇岛wannafly[数论]学习笔记
  • 原文地址:https://www.cnblogs.com/bingoyes/p/11747142.html
Copyright © 2020-2023  润新知