当前位置:网站首页>C. Divan and bitwise operations
C. Divan and bitwise operations
2022-06-30 05:22:00 【whitewall_ nine】
// Problem: C. Divan and bitwise operations
// Contest: Codeforces - Codeforces Round #757 (Div. 2)
// URL: https://codeforces.com/contest/1614/problem/C
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// 2022-02-16 00:46:49
//
// Powered by CP Editor (https://cpeditor.org)
#include<bits/stdc++.h>
using namespace std;
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,l,r) for(int i=(l);i>=(r);i--)
#define ll long long
#define pii pair<int, int>
#define mset(s,t) memset(s,t,sizeof(t))
#define mcpy(s,t) memcpy(s,t,sizeof(t))
#define fir first
#define pb push_back
#define sec second
#define sortall(x) sort((x).begin(),(x).end())
inline int read () {
int x = 0, f = 0;
char ch = getchar();
while (!isdigit(ch)) f |= (ch=='-'),ch= getchar();
while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
return f?-x:x;
}
template<typename T> void print(T x) {
if (x < 0) putchar('-'), x = -x;
if (x >= 10) print(x/10);
putchar(x % 10 + '0');
}int n, m;
const int mod = 1e9 + 7;
ll qmi (ll a, ll b) {
ll ans = 1;
while (b) {
if (b & 1) ans = ans * a %mod;
a= a * a%mod;
b >>= 1;
}
return ans;
}
void solve() {
cin >> n >> m;
ll x= 0;
for (int i = 1; i <= m; i++) {
int l, r;
cin >> l >> r;
int t;
cin >> t;
x |= t;
}
cout << x * qmi(2, n - 1) %mod << endl;
}
int main () {
int t;
cin >> t;
while (t --) solve();
return 0;
}
I wanted to pass this question at first l,r Construct an array , Then find the subsequence result . But constructing an array is too complicated . Because we finally find the XOR sum of all subsequences , Or no additional contribution 1, So don't consider the specific number . If we've got a bunch of numbers , For someone , We ask for his total contribution to all sequences , We divide numbers into A,B Two sets ,A Indicates this bit 0,B Indicates that this digit is 1, Result If this one is 0, Then we choose 0,1,2,.... Are all the same , Because XOR 0 For the original number face 1, We can only choose an odd number of times , Because even times is 0, Only an odd number of times can you contribute . Then the result is 2^(m - 1) The total contribution is 2^(A) * 2^(B - 1) = 2^(n -1) Then by recording the weight of each bit . Of x. The final result is x*(2^(n - 1)); There is no need to consider specific arrays .
边栏推荐
- Ugui uses its own function to realize reverse mask
- Nestjs introduction and environment construction
- 很紧张,第一天做软件测试,需要做什么?
- Question mark (?) in Cron expression Use of
- Unity shader flat shadow
- 旋转框目标检测mmrotate v0.3.1入门
- Unity dotween plug-in description
- pytorch中常用损失函数总结
- Unity2019.3.8f1 development environment configuration of hololens2
- Super comprehensive summary | related improvement codes of orb-slam2 / orb-slam3!
猜你喜欢

Database base (Study & review for self use)

【VCS+Verdi聯合仿真】~ 以計數器為例

Force buckle 977 Square of ordered array

Installation and getting started with pytoch

Unit asynchronous jump progress

Use the code cloud publicholiday project to determine whether a day is a working day

Intellj idea generates jar packages for projects containing external lib to other projects. The method refers to the jar package written by itself

终端便捷ssh(免密)连接

How to judge the quality of network transformer? What symptom is network filter transformer broken?

Unity ugui text value suspended enlarged display add text background
随机推荐
Chapter 8 primitive processing of OpenGL super classic (version 7)
PWN Introduction (2) stack overflow Foundation
14x1.5cm竖向标签有点难,VFP调用BarTender来打印
Unity project hosting platform plasticscm (learn to use 1)
Unity publishing /build settings
Some problems encountered in unity steamvr
Vfpbs uploads excel and saves MSSQL to the database
Virtual and pure virtual destructions
VFPBS上传EXCEL并保存MSSQL到数据库中
旋转框目标检测mmrotate v0.3.1 学习配置
unity 扫描圈 圆扩展方法
Responsive flow layout
【 VCS + Verdi joint simulation】 ~ Taking Counter as an Example
E: Topic focus
C # uses monopinvokecallback to directly call back C # function
Set a plane to camera viewport
Unit asynchronous jump progress
How to use js to control the scroll bar of moving div
pytorch中常用损失函数总结
Unity + hololens common basic functions