%%%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. HTML_案例(注册案例CSS版)

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. 基于第三方开源库的OPC服务器开发指南(4)——后记:与另一个开源库opc workshop库相关的问题

    平心而论,我们从样例服务器的代码可以看出,利用LightOPC库开发OPC服务器还是比较啰嗦的,网上有人提出opc workshop库就简单很多,我千辛万苦终于找到一个05年版本的workshop库源 ...

  3. Ubuntu Apache vhost不执行php小记

    运行环境: Ubuntu : 16.04 PHP: 5.6.36 Apache: 2.4.18 出现/var/www/html 文件夹下的 php文件能够执行 vhost 配置文件的DocumentR ...

  4. openwrt_ipsec_function.sh 分析

    #!/bin/sh # # Copyright (C) Vitaly Protsko <villy@sft.ru> errno= # get_fieldval gate src " ...

  5. (依赖注入框架:Ninject ) 一 手写依赖注入

    什么是依赖注入? 这里有一个场景:战士拿着刀去战斗: 刀: class Sword { public void Hit(string target) { Console.WriteLine($&quo ...

  6. undertow服务器

    参考地址:http://undertow.io/undertow-docs/undertow-docs-1.3.0/index.html 1.引入相关jar <dependencies> ...

  7. luoguP1890 gcd区间 [st表][gcd]

    题目描述 给定一行n个正整数a[1]..a[n]. m次询问,每次询问给定一个区间[L,R],输出a[L]..a[R]的最大公因数. 输入输出格式 输入格式: 第一行两个整数n,m. 第二行n个整数表 ...

  8. 判断MDI窗体的子窗体是否存在

    //***************************************************************************//函 数名: CreateForm//返 回 ...

  9. python定时任务模块APScheduler

    一.简单任务 定义一个函数,然后定义一个scheduler类型,添加一个job,然后执行,就可以了 5秒整倍数,就执行这个函数 # coding:utf-8 from apscheduler.sche ...

  10. mysql用户管理和pymysql

    mysql用户管理 为了使不同的人员访问到对应身份的数据库资源,每个人都有不同的权限. mysql本质上是一款cs软件,它具备用户认证,那么如何实现呢?那就是写入文件,但是在mysql把文件称作表,只 ...