%%%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的更多相关文章

  1. 背水一战 Windows 10 (31) - 控件(按钮类): ButtonBase, Button, HyperlinkButton, RepeatButton, ToggleButton, AppBarButton, AppBarToggleButton

    [源码下载] 背水一战 Windows 10 (31) - 控件(按钮类): ButtonBase, Button, HyperlinkButton, RepeatButton, ToggleButt ...

  2. Contest - 2014 SWJTU ACM 手速测试赛(2014.10.31)

    题目列表: 2146 Problem A [手速]阔绰的Dim 2147 Problem B [手速]颓废的Dim 2148 Problem C [手速]我的滑板鞋 2149 Problem D [手 ...

  3. 17.10.31&11.01

    10.31模拟考试 Prob.1(AC)裸的矩阵幂 Prob.2(WA)(类似括号匹配求合法方案数) 卡特兰数的一个模型运用.可以推出一个式子(推导方法一个erge讲的,一个骚猪讲的) Prob.3( ...

  4. 10.31 正睿停课训练 Day13

    目录 2018.10.31 正睿停课训练 Day13 A Poker(期望) B Label(高斯消元) C Coin(二分图染色 博弈) 考试代码 A(打表) B 2018.10.31 正睿停课训练 ...

  5. XSY3244 10.31 D

    XSY3244 10.31 D 题意: ​ 数轴上有\(N\)只老鼠\(M\)个洞,每个洞有一个容量,求所有老鼠进洞的最小代价.(\(N,M\leq1000000\),时限\(2s\)) 题解: ​ ...

  6. Ubuntu 19.10 发布 | 云原生生态周报 Vol. 24

    作者 | 木苏.进超.冬岛.元毅.心水.衷源 业界要闻 1.云原生编程语言 Pulumi 1.0 pulumi ,一款中立的开源云开发平台,Pulumi 支持多语言.混合云环境.完全可扩展.初期支持 ...

  7. [Linux] 在 Ubuntu 19.10 上开启 SSH 服务并允许远程登录

    在 Ubuntu 19.10 上安装 SSH,并开启服务 0.检查并确认系统当前是否已安装SSH: sudo ps -e | grep ssh 如果只有 ssh-agent 说明 ssh-server ...

  8. [Linux] 树莓派 4B 安装 Ubuntu 19.10 (Eoan Ermine) IOT 版

    硬件:Raspberry Pi 4B系统:Ubuntu 19.10 (Eoan Ermine) for IOT官网:https://ubuntu.com/download/iot/raspberry- ...

  9. Ubuntu 19.10 安装 jupyter

    安装pip3 ubuntu 19.10 已经没有python了,取代的是python3. 执行sudo apt install python3-pip安装pip3 安装jupyter 执行sudo p ...

  10. Ubuntu 19.10将使用GCC 9作为默认编译器

    作为我们这一周期一直期待的变化,Ubuntu 19.10升级到GCC 9作为GCC 8的默认系统编译器. Ubuntu 19.10(和Ubuntu 20.04 LTS)将使用GCC 9 stable作 ...

随机推荐

  1. IntelliJ IDEA创建springboot项目

    1.创建新项目. 2. 3.Group 是包名,Artifact是项目名. 4.springboot版本尽量选择最高版本,且不要选择SNAPSHOP版本. 5.路径可自定义,默认为D://IDEA/M ...

  2. LA2218 Triathlon /// 半平面交 oj22648

    题目大意: 铁人三项分连续三段:游泳 自行车 赛跑 已知各选手在每个单项中的速度v[i],u[i],w[i] 设计每个单项的长度 可以让某个特定的选手获胜 判断哪些选手有可能获得冠军 输出n行 有可能 ...

  3. 2018-8-10-使用-IncrediBuild-提升-VisualStudio-编译速度

    title author date CreateTime categories 使用 IncrediBuild 提升 VisualStudio 编译速度 lindexi 2018-08-10 19:1 ...

  4. XMLHTTPRequest状态status完整列表

    当用户试图通过 HTTP 访问一台正在运行 Internet 信息服务 (IIS) 的服务器上的内容时,IIS 返回一个表示该请求的状态的数字代码.状态代码可以指明具体请求是否已成功,还可以揭示请求失 ...

  5. [JZOJ3691] 【CF414E】Mashmokh's Designed tree

    题目 题目大意 给你一棵树,接下来对这棵树进行三种操作: 1.询问两点之间的距离. 2.让某个点变为它原来的第\(h\)个祖先的最后一个儿子. 3.求\(dfs\)序中最后一个深度为\(k\)的点. ...

  6. python 毫秒时间戳转日期

    import time import datetime timestamp = 1570774556514 # 转换成localtime time_local = time.localtime(tim ...

  7. ASP.NET的底层体系2

    文章引导 1.ASP.NET的底层体系1 2.ASP.NET的底层体系2 引言 接着上一篇ASP.NET的底层体系1我们继续往下走 一.System.Web.HttpRuntime.ProcessRe ...

  8. 17.splash_case03

    # python执行lua脚本 import requests from urllib.parse import quote lua = ''' function main(splash) retur ...

  9. JS流程控制语句 做判断(if语句)if语句是基于条件成立才执行相应代码时使用的语句。语法:if(条件) { 条件成立时执行代码}

    做判断(if语句) if语句是基于条件成立才执行相应代码时使用的语句. 语法: if(条件) { 条件成立时执行代码} 注意:if小写,大写字母(IF)会出错! 假设你应聘web前端技术开发岗位,如果 ...

  10. 【daydayup】ceshuChat

    时时当勉励,岁月不待人.珍惜时间伐~ 先看看项目运行的效果 这个是在本地环境打开了两个8080端口进行模拟运行的. 先放下作者的开源地址:https://github.com/ceshu/ceshuC ...