当前位置:网站首页>NewOJ Week 2---BCD
NewOJ Week 2---BCD
2022-06-11 10:28:00 【WAWA源】
B.Pow Set—约数分解
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define int long long
set<vector<pair<int,int>>>S;
int n,m;
void get_factor(int x,int y)
{
vector<pair<int,int>>pvec;
for(int i=2;i<=x/i;i++)
{
int cnt=0;
if(x%i==0)
{
while(x%i==0)x/=i,cnt++;
pvec.push_back({
i,cnt*y});
}
}
if(x>1)pvec.push_back({
x,y});
S.insert(pvec);
}
signed main()
{
cin>>n>>m;
for(int i=2;i<=n;i++)
for(int j=2;j<=m;j++)
get_factor(i,j);
cout<<S.size()<<endl;
}
C.Sum of Interval—公式推导
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
#define int long long
const int N = 200010 , mod = 1e18;
signed main()
{
int n,res=0;
cin>>n;
for(int i=1;i<=n;i++)
{
int x;cin>>x;
res+=x*i*(n-i+1);
}
cout<<res<<'\n';
}
D.极差—线段树板子题
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
#define int long long
const int N = 50010 , mod = 1e18;
int tr_max[N*4];
int tr_min[N*4];
int a[N];
void build(int u,int l,int r)
{
if(l==r)
{
tr_max[u]=tr_min[u]=a[l];
return ;
}
int mid=l+r>>1;
build(u<<1,l,mid);
build(u<<1|1,mid+1,r);
tr_max[u]=max(tr_max[u<<1],tr_max[u<<1|1]);
tr_min[u]=min(tr_min[u<<1],tr_min[u<<1|1]);
}
int maxv=0,minv=0;
void query(int u,int l,int r,int L,int R)
{
if(L<=l&&R>=r)
{
maxv=max(maxv,tr_max[u]);
minv=min(minv,tr_min[u]);
return ;
}
int mid=l+r>>1;
if(L<=mid)query(u<<1,l,mid,L,R);
if(R>mid)query(u<<1|1,mid+1,r,L,R);
}
signed main()
{
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++)cin>>a[i];
build(1,1,n);
while(m--)
{
int l,r;
cin>>l>>r;
maxv=0;
minv=1e9+7;
query(1,1,n,l,r);
cout<<maxv-minv<<'\n';
}
}
边栏推荐
- [high concurrency] the interviewer of ant financial asked me about thread pool!!
- 微信小程序之点餐系统附源码
- 金仓数据库KingbaseES中的PL/SQL 编译检查
- NGUI,选择性别男女
- 班组级安全培训,新员工入职培训教育课件,全内容PPT套用
- Cadence OrCAD capture design method to avoid misoperation graphic tutorial
- Review handwritten questions in interview -- function interception and jitter
- ZigBee模块通信协议的树形拓扑组网结构
- Some understanding of inductive bias
- Correct opening method of RPC | understand go native net/rpc package
猜你喜欢

Pyramidtnt: TNT with characteristic pyramid structure

Reprint: linearlayout+fragment to achieve the lower navigation bar effect

MySQL基础篇常用约束总结上篇

Jedislock redis distributed lock implementation

选择DC-DC开关电源控制器的实战过程

电子设备辐射EMC整改案例

Mysql--事务

Bcgcontrolbar Library Professional Edition, fully documented MFC extension class

Xilinx pin constraint file xdc

Initial deployment of Servlet
随机推荐
Es6新特性——箭头函数
Some code fragments of a universal and confession wall system developed by PHP
Fix the problem that uicollectionview does not reach the bottom security zone
Finite cyclic group
Mysql--索引
详解2.5G/5G/10G Base-T以太网接口物理层一致性测试!
Pyramidtnt: TNT with characteristic pyramid structure
MD5 learning
Xilinx pin constraint file xdc
After four years of outsourcing, it was abandoned
Wechat applet ordering system with source code
金仓数据库KingbaseES中的sys_checksums坏块检测功能
Review handwritten questions in interview -- function interception and jitter
C语言校园导游咨询系统
[Objective-C] dynamically create controls
MySQL transaction
Ugui picture wall
About CI framework batch export to compressed file
利用PHP开发的一款万能、表白墙系统部分代码片段
详述用网络分析仪测量DC-DC和PDN