给你一个n个初始元素都为1的序列和m个询问q。

询问格式为:l r x(x为2or3)

最后求1~n所有数的GCD

GCD:把每个数分别分解质因数,再把各数中的全部公有质因数提取出来连乘,所得的积就是这几个数的最大公约数。

#include<cstdio>
#include<string>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<cstring>
#include<set>
#include<queue>
#include<algorithm>
#include<vector>
#include<map>
#include<cctype>
#include<stack>
#include<sstream>
#include<list>
#include<assert.h>
#include<bitset>
#include<numeric>
#define debug() puts("++++")
#define gcd(a,b) __gcd(a,b)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define fi first
#define se second
#define pb push_back
#define sqr(x) ((x)*(x))
#define ms(a,b) memset(a,b,sizeof(a))
#define sz size()
#define be begin()
#define pu push_up
#define pd push_down
#define cl clear()
#define lowbit(x) -x&x
#define all 1,n,1
#define mod 998244353 #define pi acos(-1.0)
#define rep(i,x,n) for(int i=(x); i<(n); i++)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;
const int INF = 1<<30;
const int maxn = 1e5+3;
const double eps = 1e-8;
const int dx[] = {-1,1,0,0,1,1,-1,-1};
const int dy[] = {0,0,1,-1,1,-1,1,-1};
int dir[2]={-1,1};
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
LL t,n,m;
LL Pow(LL a, LL b)
{
LL res=1;
while(b)
{
if(b&1)
res=(res%mod * a%mod)%mod;
a = a%mod*a%mod;
b>>=1;
}
return res%mod;
}
LL a[maxn],b[maxn];
int main()
{
scanf("%lld",&t);
while(t--)
{
ms(a,0),ms(b,0);
scanf("%lld%lld",&n,&m);
while(m--)
{
LL l,r,x;
scanf("%lld%lld%lld",&l,&r,&x);
if(x==2)
{
a[l]++,a[r+1]--; //差分标记因子含有2的数、区间加维护2or3的操作数
}
else
{
b[l]++,b[r+1]--;
}
}
LL m1=a[1],m2=b[1];
for(int i=2;i<=n;i++)
{
a[i]+=a[i-1]; //前缀和维护序列本身,而序列记录2的操作数即个数,得到具体每个数的操作数
b[i]+=b[i-1];
m1=min(m1,a[i]); //2的最小操作数
m2=min(m2,b[i]);
}
LL ans = (Pow(2,m1)%mod*Pow(3,m2)%mod)%mod;
printf("%lld\n",ans);
}
}
/*
2
5 3
1 3 2
3 5 2
1 5 3
6 3
1 2 2
5 6 2
1 6 2 6 2
【题意】 【类型】 【分析】 【时间复杂度&&优化】 【trick】 【数据】 */

最新文章

  1. Android开发案例 - 图库
  2. Ubuntu下设置(增加/删除)开机启动项
  3. Android开发(三十一)——重复引用包错误Conversion to Dalvik format failed
  4. Car的旅行路线(codevs 1041)
  5. 第十一篇 SQL Server安全审核
  6. android开发系列之友盟统计集成
  7. javascript操作注册表
  8. Office 2010 &amp; SharePoint 2010 Service Pack 2现在可用啦
  9. php调用API支付接口(使用第三方接口,调用的天工接口。)
  10. 为什么非全站升级HTTPS不可?
  11. ResourceBundleViewResolver
  12. hdu 5591 BestCoder Round #65(博弈)
  13. mysql的btree和hash的区别
  14. VUE引入字体图标库
  15. webpack打包vue项目,资源路径如何从绝对路径改为相对路径?css中的图片资源如何修改配置?
  16. 灰熊:在这6个信息流和DSP平台投放后,我总结了这些血泪经验!
  17. Java学习笔记四:三目运算符与字符串连接符等
  18. 枚举类 enum,结构体类 struct
  19. 关于ionic2打包android时gradle下载不了的解决方法(附:简单优化启动速度彩蛋)
  20. Java学习笔记(十五):import关键字

热门文章

  1. Java设计模式の工厂模式
  2. springboot整合thumbnailator实现图片压缩
  3. js for等循环 跳出多层循环
  4. Android Studio 中引入Library
  5. feign hystrix 线程池伸缩控制
  6. hdfs文件上传机制与namenode元数据管理机制
  7. 一个基于时间注入的perl小脚本
  8. MySQL当中的case when then
  9. uboot makefile构建分析
  10. linux arm的存储分布那些事之一