19-10-31-B
%%%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
先口古
19-10-31-B的更多相关文章
- 背水一战 Windows 10 (31) - 控件(按钮类): ButtonBase, Button, HyperlinkButton, RepeatButton, ToggleButton, AppBarButton, AppBarToggleButton
[源码下载] 背水一战 Windows 10 (31) - 控件(按钮类): ButtonBase, Button, HyperlinkButton, RepeatButton, ToggleButt ...
- Contest - 2014 SWJTU ACM 手速测试赛(2014.10.31)
题目列表: 2146 Problem A [手速]阔绰的Dim 2147 Problem B [手速]颓废的Dim 2148 Problem C [手速]我的滑板鞋 2149 Problem D [手 ...
- 17.10.31&11.01
10.31模拟考试 Prob.1(AC)裸的矩阵幂 Prob.2(WA)(类似括号匹配求合法方案数) 卡特兰数的一个模型运用.可以推出一个式子(推导方法一个erge讲的,一个骚猪讲的) Prob.3( ...
- 10.31 正睿停课训练 Day13
目录 2018.10.31 正睿停课训练 Day13 A Poker(期望) B Label(高斯消元) C Coin(二分图染色 博弈) 考试代码 A(打表) B 2018.10.31 正睿停课训练 ...
- XSY3244 10.31 D
XSY3244 10.31 D 题意: 数轴上有\(N\)只老鼠\(M\)个洞,每个洞有一个容量,求所有老鼠进洞的最小代价.(\(N,M\leq1000000\),时限\(2s\)) 题解: ...
- Ubuntu 19.10 发布 | 云原生生态周报 Vol. 24
作者 | 木苏.进超.冬岛.元毅.心水.衷源 业界要闻 1.云原生编程语言 Pulumi 1.0 pulumi ,一款中立的开源云开发平台,Pulumi 支持多语言.混合云环境.完全可扩展.初期支持 ...
- [Linux] 在 Ubuntu 19.10 上开启 SSH 服务并允许远程登录
在 Ubuntu 19.10 上安装 SSH,并开启服务 0.检查并确认系统当前是否已安装SSH: sudo ps -e | grep ssh 如果只有 ssh-agent 说明 ssh-server ...
- [Linux] 树莓派 4B 安装 Ubuntu 19.10 (Eoan Ermine) IOT 版
硬件:Raspberry Pi 4B系统:Ubuntu 19.10 (Eoan Ermine) for IOT官网:https://ubuntu.com/download/iot/raspberry- ...
- Ubuntu 19.10 安装 jupyter
安装pip3 ubuntu 19.10 已经没有python了,取代的是python3. 执行sudo apt install python3-pip安装pip3 安装jupyter 执行sudo p ...
- Ubuntu 19.10将使用GCC 9作为默认编译器
作为我们这一周期一直期待的变化,Ubuntu 19.10升级到GCC 9作为GCC 8的默认系统编译器. Ubuntu 19.10(和Ubuntu 20.04 LTS)将使用GCC 9 stable作 ...
随机推荐
- 大神给你分析HTTPS和HTTP的区别
今天在做雅虎的时候,发现用第三方工具截取不到客户端与服务端的通讯,以前重来没碰到过这种情况,仔细看了看,它的url请求时基于https的,gg了下发现原来https协议和http有着很大的区别.总的来 ...
- 好消息:Dubbo & Spring Boot要来了
Duboo和Spring Boot都是非常优秀的框架,现在它们要结合了.为了简化Dubbo开发集成,阿里Dubbo团队将发布基于Spring Boot的版本,可快速上手Dubbo的分布式开发,并提供了 ...
- 关于合并pdf文件出现的问题
输出端出现以下问题: PdfReadWarning: Xref table not zero-indexed. ID numbers for objects will be 解决方案: import ...
- 【Latex】一些使用
http://www.mohu.org/info/symbols/symbols.htm GG..研究个公式就搞这么晚了..还不知道那三个报错的是怎么回事.. 意识模糊..睡了睡了. # Latex ...
- jdbc_mysql----函数助手参数化
第一个值填写的是文件路径 第二个值填写的是从第几个开始执行,从0开始
- HIVE文件
注册表的本地实体文件, 察看位置,以及映射本地文件到注册表中的位置, HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\hivelist 在这里写 ...
- Spring Cloud高级视频
Spring Cloud高级视频 第一章 微服务架构概述 第二章 开始使用Spring Cloud实战微服务 第三章 服务提供者与服务消费者 第四章 服务发现与服务注册 第五章 使用Hystrix保护 ...
- iOS开发系列-HTTPS
HTTPS 网景在1994年创建了HTTPS,并应用在网景导航者浏览器中. 最初,HTTPS是与SSL一起使用的:在SSL逐渐演变到TLS. HTTPS协议与HTTP协议的一些不同: http是超文本 ...
- Centos 6.5 python版本升级到2.7.8
Centos6.5默认的 python版本是2.6 为了使用aliyuncli工具,直接用pip安装aliyuncli提示错误. 所以决定升级下python版本,但是yum依赖于python2.6,升 ...
- 【转】keepalived+mysql
https://www.cnblogs.com/gomysql/p/3856484.html MySQL的高可用方案有很多,比如Cluster,MMM,MHA,DRBD等,这些都比较复杂,我前面的文章 ...