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. EF Core 2.0 执行原始查询如何防止SQL注入

    using (var context = new EFCoreDbContext()) { var searchString = "Jeffcky Wang"; Formattab ...

  2. Ubuntu Server Swap 分区设置

    方案一:仅在内存耗尽的情况下才使用 swap 分区 # 首先进入 sudo 模式 sysctl vm.swappiness=0 # 临时生效 echo "vm.swappiness = 0& ...

  3. High load average analyze

    https://www.tummy.com/articles/isolating-heavy-load/ https://www.tecmint.com/understand-linux-load-a ...

  4. 简单即时通讯、聊天室--java NIO版本

    实现的功能: 运行一个服务端,运行多个客户端.在客户端1,发送消息,其余客户端都能收到客户端1发送的消息. 重点: 1.ByteBuffer在使用时,注意flip()方法的调用,否则读取不到消息. 服 ...

  5. 在论坛中出现的比较难的sql问题:42(动态行转列 考勤时间动态列)

    原文:在论坛中出现的比较难的sql问题:42(动态行转列 考勤时间动态列) 所以,觉得有必要记录下来,这样以后再次碰到这类问题,也能从中获取解答的思路.

  6. (面试题)请用C语言实现在32位环境下,两个无符号长整数相加的函数,相加之和不能存储在64位变量中

    分析:长整数相加,将结果分为高位和低位部分,分别保存在两个32整数中. 比如:unsigned int a = 0xFFFFFFFF, unsigned int b = 0x1, 结果用unsigne ...

  7. Bigdecimal除法异常

    1.异常信息摘要(详细请见文末): java.lang.ArithmeticException: Non-terminating decimal expansion; no exact represe ...

  8. Go part 6 接口,接口排序,接口嵌套组合,接口与类型转换,接口断言

    接口 接口是一种协议,比如一个汽车的协议,就应该有 “行驶”,“按喇叭”,“开远光” 等功能(方法),这就是实现汽车的协议规范,完成了汽车的协议规范,就实现了汽车的接口,然后使用接口 接口的定义:本身 ...

  9. python火爆背后

    Python是一种非常好的编程语言,也是目前非常有前途的一门学科.有很多工作要做,而且薪水也很高,这已经成为每个人进入IT行业的首选.那么Python能做什么呢?为什么这么热? 那么Python能做什 ...

  10. ubuntu无法安装usb驱动

    第一步: 输入命令 lsusb 箭头指向的就是连接的手机 第二步: 输入命令,新建并打开文件 sudo gedit /etc/udev/rules.d/-android.rules [注意]如果提示没 ...