19-10-31-B
2024-09-06 10:31:19
%%%B哥
ZJ一下:
开题。
发现
语文考试????
我不认识XD。老帅哥救我!
后来……
对什么取模???
什么玩意??输入什么??
满足啥??
全是亻
啊!
后来才知道是题楔×了
不管了。
然后发现T1是慢速乘?
我以为是自然数幂和,结果不是。
就一个柿子。
T2想了半天……后来丢一个 set 乱搞。
T3打暴力,后来没调出来……
这是TJ:
T1
慢速乘(=快速加$\Leftarrow$快速幂)
直接等差数列求和。
//sum #include <iostream>
#include <cstring>
#include <cstdio>
#define LL long long using namespace std; LL lx,ly,rx,ry,mod;
LL li,co;
LL mul(LL a,LL b){
LL res=0;
a%=mod;
while(b){
if(b&1)res=(res+a)%mod;
a=(a+a)%mod;
b>>=1;
}
return res;
}
int main(){
#ifndef LOCAL
freopen("sum.in" ,"r",stdin);
freopen("sum.out","w",stdout);
#endif
cin>>lx>>ly>>rx>>ry>>mod;
li=rx-lx+1;
co=ry-ly+1;
LL ans=0;
if(co&1) ans=(ans+mul(mul((co+1)/2, co),li))%mod;
else ans=(ans+mul(mul( co+1 ,co/2),li))%mod;
if(li&1) ans=(ans+mul(mul((li-1)/2,li ),co))%mod;
else ans=(ans+mul(mul( li-1 ,li/2),co))%mod;
LL val=((lx%mod+ly%mod)%mod-2+mod)%mod;
ans=(ans+mul(mul(li,co),val))%mod;
cout<<ans<<endl;
}
T2
倍增。
这个题是倍增思想的普适思路。
区间合法就先更新,然后将增量倍增。
区间非法就不更新,然后将增量减半。
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#define N 555555
#define LL long long using namespace std; LL lim;
int pn;
LL bo[N],gi[N];
int ans=0;
vector<LL>a,b;
LL check(int l,int r){
a.clear();
b.clear();
for(int i=l;i<=r;i++){
a.push_back(bo[i]);
b.push_back(gi[i]);
}
sort(a.begin(),a.end());
sort(b.begin(),b.end());
LL dat=0;
for(int i=0;i<a.size();i++){
dat+=a[i]*b[i];
}
// cout<<l<<" "<<r<<" "<<dat<<endl;
return dat;
}
int main(){
#ifndef LOCAL
freopen("pair.in" ,"r",stdin);
freopen("pair.out","w",stdout);
#endif
cin.sync_with_stdio(false);
cin>>pn>>lim;
for(int i=1;i<=pn;i++)
cin>>bo[i];
for(int i=1;i<=pn;i++)
cin>>gi[i];
for(int i=1;i<=pn;){
int p=1,r=i;
ans++;
while(p!=0){
if(r+p<=pn&&check(i,r+p)<=lim){
r+=p;
p*=2;
}
else p/=2;
}
i=r+1;
}
cout<<ans<<endl;
}
T3
先口古
最新文章
- CSS 3学习——transform 2D转换
- GJM : C#语言学习笔记
- ansible 初探nginx安装
- 2.goldengate日常维护命令(转载)
- 关于一次oracle sqlplus可登陆,但监听起不来的解决。由于listener.log文件超过4G
- jsp页面格式时间yy-mm-dd
- 3、android notification 详细用法
- FragmentTabHost
- Spring IOC容器中注入bean
- css中 中文字体(font-family)的标准英文名称
- Pair of Numbers
- poi实现Excel导出
- C:\Program Files (x86)\Common Files\microsoft shared\TextTemplating\11.0
- java ssh
- 【NOIP2015】字串
- Oracle 执行计划(Explain Plan) 说明
- 2018-2019-2 20165232 《网络对抗技术》 Exp6 信息搜集与漏洞扫描
- JavaScript基础函数---李老师的
- 使用HDTune规避硬盘上损坏的扇区
- 『计算机视觉』Mask-RCNN_推断网络其五:目标检测结果精炼
热门文章
- 【CF1215F】 Radio Stations
- 【CF516D】Drazil and Morning Exercise
- 007-Java可变个数形参重载【数组和...】
- github代码推送
- mysql的几种启动方式
- INSTALL_FAILED_TEST_ONLY oppor11p 安装时出现的问题
- Laravel Illuminate\Http\Exceptions\PostTooLargeException
- ArcGIS Server 10.x查询管理用户名和修改管理员密码
- (依赖注入框架:Ninject ) 一 手写依赖注入
- chrome的驱动安装