hdu 3 * problem
hdu 6182
给出 $n$
求 $\sum_{i = 1} ^ {\infty} (i * i <= n)$
暴力枚举
hdu 6186
给出 $n$ 个数
$1e6$ 次询问,每次询问这 $n$ 个数不包含第 $p$ 个时的 $xor, or and$ 的值
前缀 + 后缀处理
hdu 6188
给出 $n$ 个数$A_i$
$a.$ 每两个相同的数对答案的贡献为 $1$
$b.$ 每相连的 $3$ 个数对答案的贡献为 $1$
每个数只能使用一次
最大化答案
贪心:取 $i,i - 1, i - 2$ 这个顺子的时候先把 $i - 1,i - 2$ 的对子取掉,取完再取 $i$ 的对子
Code
6182
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath> using namespace std; long long Ksm(long long a, long long b) {
long long ret = ;
while(b) {
if(b & ) ret = ret * a;
a = a * a;
b >>= ;
}
return ret;
} #define LL long long LL num[]; int main() {
for(LL i = ; i <= ; i ++) num[i] = Ksm(i, i);
LL a;
while(cin >> a) {
if(a == ) {
cout << << "\n";
continue;
}
int i;
for(i = ; i <= ; i ++) {
if(num[i] > a) break;
}
cout << i - << "\n";
} return ;
}
6186
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath> using namespace std; #define LL long long const int N = 1e5 + ;
int A[N];
int And[N], Or[N], Xor[N];
int And2[N], Or2[N], Xor2[N];
int n, m; #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;
} int main() {
while(scanf("%d%d", &n, &m) == ) {
And[] = And2[n + ] = ~ ;
Xor[] = Xor2[n + ] = ;
Or[] = Or2[n + ] = ;
for(int i = ; i <= n; i ++) A[i] = read(); //cin >> A[i];
for(int i = ; i <= n; i ++) And[i] = (And[i - ] & A[i]);
for(int i = ; i <= n; i ++) Or[i] = (Or[i - ] | A[i]);
for(int i = ; i <= n; i ++) Xor[i] = (Xor[i - ] ^ A[i]);
for(int i = n; i >= ; i --) And2[i] = (And2[i + ] & A[i]);
for(int i = n; i >= ; i --) Or2[i] = (Or2[i + ] | A[i]);
for(int i = n; i >= ; i --) Xor2[i] = (Xor2[i + ] ^ A[i]);
for(; m; m --) {
int p = read();
printf("%d ", (And[p - ] & And2[p + ]));
printf("%d ", (Or[p - ] | Or2[p + ]));
printf("%d\n", (Xor[p - ] ^ Xor2[p + ]));
}
} return ;
}
6188
#include <iostream>
#include <cstdio>
#include <cstring> const int N = 1e6 + ; #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;
} int n;
int T[N]; int main() {
while(~ scanf("%d", &n)) {
memset(T, , sizeof T);
int Answer = ;
for(int i = ; i <= n; i ++) T[read()] ++;
for(int i = ; i <= (int)1e6; i ++) {
if(i >= && T[i] && T[i - ] && T[i - ]) {
Answer ++;
T[i] --, T[i - ] --, T[i - ] --;
}
Answer += (T[i] >> );
T[i] %= ;
}
printf("%d\n", Answer);
} return ;
}
hdu 3 * problem的更多相关文章
- HDU 6343.Problem L. Graph Theory Homework-数学 (2018 Multi-University Training Contest 4 1012)
6343.Problem L. Graph Theory Homework 官方题解: 一篇写的很好的博客: HDU 6343 - Problem L. Graph Theory Homework - ...
- hdu String Problem(最小表示法入门题)
hdu 3374 String Problem 最小表示法 view code#include <iostream> #include <cstdio> #include &l ...
- HDU 6343 - Problem L. Graph Theory Homework - [(伪装成图论题的)简单数学题]
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6343 Time Limit: 2000/1000 MS (Java/Others) Memory Li ...
- HDU 5687 Problem C 【字典树删除】
传..传送:http://acm.hdu.edu.cn/showproblem.php?pid=5687 Problem C Time Limit: 2000/1000 MS (Java/Others ...
- HDU 6342.Problem K. Expression in Memories-模拟-巴科斯范式填充 (2018 Multi-University Training Contest 4 1011)
6342.Problem K. Expression in Memories 这个题就是把?变成其他的使得多项式成立并且没有前导零 官方题解: 没意思,好想咸鱼,直接贴一篇别人的博客,写的很好,比我的 ...
- HDU 6336.Problem E. Matrix from Arrays-子矩阵求和+规律+二维前缀和 (2018 Multi-University Training Contest 4 1005)
6336.Problem E. Matrix from Arrays 不想解释了,直接官方题解: 队友写了博客,我是水的他的代码 ------>HDU 6336 子矩阵求和 至于为什么是4倍的, ...
- HDU 5687 Problem C(Trie+坑)
Problem C Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Tota ...
- HDU 6430 Problem E. TeaTree(虚树)
Problem E. TeaTree Problem Description Recently, TeaTree acquire new knoledge gcd (Greatest Common D ...
- HDU 4910 Problem about GCD 找规律+大素数判断+分解因子
Problem about GCD Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- HDU 5688 Problem D map
Problem D Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total S ...
随机推荐
- docker 实践四:数据管理
这篇是关于 docker 的数据管理. 注:环境为 CentOS7,docker 19.03. 一般容器中管理数据主要有两种方式: 数据卷(Data Volumes):容器内数据直接映射到本地主机环境 ...
- docker xfs卡死
原因 docker在xfs文件系统中,过于频繁create/destory container.pull/push image,当thin pool满时,DeviceMapper后端默认文件系统xfs ...
- 深夜扒一扒Android的发展史
说道,Android的发展史,我们就不得不先来了解一下手机的发展史 Android之前的时代 1831年英国的法拉第发现了电磁感应现象,麦克斯韦进一步用数学公式阐述了法拉第等人的研究成果,并把电磁感应 ...
- 【字符串hash】DNA
DNA 题目描述 小X身为奆老,兴趣爱好广泛,他还非常喜欢研究DNA序列……小X进行了一项关于DNA序列研究,发现人某条染色体上的一段DNA序列中连续的k个碱基组成的碱基序列与做题的AC率有关!于是他 ...
- Spring Boot配置文件yml讲解--行内对象的配置方式
yml行内对象的配置方法,一般是采取 上面的缩进方式,我只想配置在一行怎么处?——
- C#合并选中EXCEL中的各个工作表
合并选中EXCEL中的各个工作表,以第一个选中的EXCEL文件里的工作表进行匹配,遍历后面的每个EXCEL文件,有相同的工作表就合并: private void button1_Click(objec ...
- opencv Cascade Classifier Training中 opencv_annotation命令
在win7 cmd中试了官方的指令opencv_annotation --annotations=/path/to/annotations/file.txt --images=/path/to/ima ...
- http://go.microsoft.com/fwlink/?linkid问题
今天不知怎的,打开一个网页出现了http://go.microsoft.com/fwlink/?linkid=XXX 烦死了,在百度搜了下方法,什么改注册表,策略模板等不见起效.其实打开IE的设置, ...
- JacksonJson的使用
JacksonJson是SpringMVC内置的json处理工具,其中有一个ObjectMapper类,可以方便的实现对json的处理: //对象转字符串 // json处理工具 private Ob ...
- 如何使用点击超链接的方式打开Android手机上的应用
在Android应用的AndroidManifest.xml里加入如下的配置片段: <action android:name="my_action"/> <cat ...