1792

模拟,转化为二进制后逐位比较

1819

线段树维护区间加

维护每个数加了多少

每次弹出栈顶元素后栈顶位置注意清空

1792

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string> using namespace std; const int N = ; int a[N], b[N];
int n; int Tow(int A[], int x) {
static int c[N];
int js = ;
while(x) {
c[++ js] = x % ;
x /= ;
}
for(int i = ; i <= js; i ++) A[i] = c[js - i + ];
return js;
} int main() {
cin >> n;
int Max = max(Tow(a, n), Tow(b, n - ));
int Answer = ;
for(int i = ; i <= Max; i ++) Answer += (a[i] != b[i]);
cout << Answer; return ;
}

1819

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string> using namespace std; #define LL long long
#define int long long
#define gc getchar()
inline int read() {int x = ; char c = gc; while(c < '' || c > '') c = gc;
while(c >= '' && c <= '') x = x * + c - '', c = gc; return x;}
inline LL read_LL() {LL x = ; char c = gc; while(c < '' || c > '') c = gc;
while(c >= '' && c <= '') x = x * + c - '', c = gc; return x;}
#undef gc const int N = 2e5 + ; LL W[N << ], F[N << ], Size[N << ];
int n;
int Num[N], js; #define lson jd << 1
#define rson jd << 1 | 1 void Build_tree(int l, int r, int jd) {
Size[jd] = (r - l + );
if(l == r) return ;
int mid = (l + r) >> ;
Build_tree(l, mid, lson), Build_tree(mid + , r, rson);
} void Push_down(int jd) {
W[lson] += Size[lson] * F[jd], W[rson] += Size[rson] * F[jd];
F[lson] += F[jd], F[rson] += F[jd];
F[jd] = ;
} LL Poi_A(int l, int r, int jd, int x) {
if(l == r) {
return W[jd];
}
if(F[jd]) Push_down(jd);
int mid = (l + r) >> ;
if(x <= mid) Poi_A(l, mid, lson, x);
else Poi_A(mid + , r, rson, x);
} void Sec_G(int l, int r, int jd, int x, int y, int num) {
if(x <= l && r <= y) {
W[jd] += Size[jd] * num;
F[jd] += num;
return ;
}
if(F[jd]) Push_down(jd);
int mid = (l + r) >> ;
if(x <= mid) Sec_G(l, mid, lson, x, y, num);
if(y > mid ) Sec_G(mid + , r, rson, x, y, num);
W[jd] = W[lson] + W[rson];
} main() {
n = read();
Build_tree(, n, );
for(int i = ; i <= n; i ++) {
char opt[]; scanf("%s", opt);
if(opt[] == 'p' && opt[] == 'u') {
int x = read(); Num[++ js] = x;
} else if(opt[] == 'p' && opt[] == 'o') {
LL Answer = Poi_A(, n, , js);
cout << Answer + Num[js] << "\n";
Sec_G(, n, , js, js, - Answer);
js --;
} else {
int k = read(), x = read();
Sec_G(, n, , , k, x);
}
}
return ;
}

hihoCoder 2 * problem的更多相关文章

  1. hihoCoder 1430 : A Boring Problem(一琐繁题)

    hihoCoder #1430 : A Boring Problem(一琐繁题) 时间限制:1000ms 单点时限:1000ms 内存限制:256MB Description - 题目描述 As a ...

  2. 【hihocoder 1424】 Asa's Chess Problem(有源汇上下界网络流)

    UVALive-7670 ICPC北京2016-C题 hihocoder 1424 题意 有个 \(N\times N\) 的棋盘,告诉你每个格子黑色(1)或白色(0),以及每对能相互交换的同行或同列 ...

  3. hihocoder #1260 : String Problem I

    题目链接   时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 我们有一个字符串集合S,其中有N个两两不同的字符串. 还有M个询问,每个询问给出一个字符串w,求有多少S中的 ...

  4. hihoCoder 1261 String Problem II

    时间限制:50000ms 单点时限:5000ms 内存限制:512MB 描写叙述 我们有一个字符串集合S,当中有N个两两不同的字符串.还有M个询问,每一个询问都会先给出一个字符串w,你须要回答下面三个 ...

  5. 【最短路】【Heap-dijkstra】hihocoder 1587 ACM-ICPC国际大学生程序设计竞赛北京赛区(2017)网络赛 J. Typist's Problem

    题意:给你一个串,仅含有a~g,且每个字母只出现最多一次.和一个光标初始位置,以及一个目标串,问你最少要多少的代价变化成目标串. 有五种操作:在光标前添加一个未出现过的字母,代价1. 删除光标前或者光 ...

  6. 【hihoCoder 1454】【hiho挑战赛25】【坑】Rikka with Tree II

    http://hihocoder.com/problemset/problem/1454 调了好长时间,谜之WA... 等我以后学好dp再来看为什么吧,先弃坑(╯‵□′)╯︵┻━┻ #include& ...

  7. 【hihocoder#1413】Rikka with String 后缀自动机 + 差分

    搞了一上午+接近一下午这个题,然后被屠了个稀烂,默默仰慕一晚上学会SAM的以及半天4道SAM的hxy大爷. 题目链接:http://hihocoder.com/problemset/problem/1 ...

  8. 【hihoCoder】1148:2月29日

    问题:http://hihocoder.com/problemset/problem/1148 给定两个日期,计算这两个日期之间有多少个2月29日(包括起始日期). 思路: 1. 将问题转换成求两个日 ...

  9. 【hihoCoder】1288 : Font Size

    题目:http://hihocoder.com/problemset/problem/1288 手机屏幕大小为 W(宽) * H(长),一篇文章有N段,每段有ai个字,要求使得该文章占用的页数不超过P ...

随机推荐

  1. 序列方差[NTT]

    也许更好的阅读体验 \(\mathcal{Description}\) 给你一个长度为\(n\)的数组\(a\) 你会得到 \(q\) 条指令, 分两种: \(1\ l\ r\ w\) 表示把 \(l ...

  2. GXOI/GZOI2019部分题解

    D1T1:与或和 对每位处理,问题变成所有内部不包含0/1的矩阵的个数,单调栈维护即可. #include<cstdio> #include<algorithm> #inclu ...

  3. git合并原则

    目前实验结果为: 假设有master和branch1,用master合并branch1时(在master分支中执行git merge branch1): 1.在同一个地方,master做了修改,bra ...

  4. Windows方便得运行jar文件

    新建文本文档,文件扩展名为“.bat”,然后输入下面内容: @echo off java -jar % pause 以后就只要拖动jar文件到这个bat文件上就行.

  5. VMWare打开centos,提示内部错误

    如题,VMWare打开centos,提示内部错误.该原因是因为服务被停止了之后没有将其启动,将其启动就解决了. CMD客户端输入命令 services.msc 将关于VM的服务启动就可以了

  6. Asp.net Identity 修改默认数据库,增加自定义字段

    visual studio 2013 先新建一个项目 选择MVC,确定 打开 Views\Shared\_Layout.cshtml文件,按自己的要求修改 改 <!DOCTYPE html> ...

  7. ORACLE锁表查询及解锁方法

    --查看锁表情况 select distinct a.sid, to_char(a.logon_time, 'YYYY-MM-DD HH24:mi:ss') loginTime, a.serial#, ...

  8. windows + Eclipse 汉化

    https://www.eclipse.org/babel/downloads.php 下载Eclipse 对应版本 汉化包解压 复制文件夹里的内容到eclipse 文件夹下对应的文件里 重启ecli ...

  9. 使用Docker发布Asp.Net Core程序到Linux

    CentOS安装Docker 按照docker官方文档来,如果有之前安装过旧版,先卸载旧版,没有的话,可跳过. sudo yum remove docker \ docker-client \ doc ...

  10. axios配置及使用(发起请求时带上token)

    1.安装 利用npm安装 npm install axios --save 2.引入即可使用 import axios from 'axios' 3.目录 4.各个文件设置: (1)env.js ex ...