BestCoder Round #66 (div.2)
构造 1002 GTW likes gt
题意:中文题面
分析:照着题解做的,我们可以倒着做,记一下最大值,如果遇到了修改操作,就把最大值减1,然后判断一下这个人会不会被消灭掉,然后再更新一下最大值。不知道其他的做法是怎么样的
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std; #define lson l, mid, o << 1
#define rson mid + 1, r, o << 1 | 1
const int N = 5e4 + 5;
const int INF = 0x3f3f3f3f;
int n, m;
int a[N], b[N], cnt[N], mx[2]; int main(void) {
int T; scanf ("%d", &T);
while (T--) {
scanf ("%d%d", &n, &m);
for (int i=1; i<=n; ++i) {
scanf ("%d%d", &a[i], &b[i]);
}
memset (cnt, 0, sizeof (cnt));
for (int c, i=1; i<=m; ++i) {
scanf ("%d", &c); cnt[c]++;
}
mx[0] = mx[1] = 0; int ans = n;
for (int i=n; i>=1; --i) {
mx[0] -= cnt[i]; mx[1] -= cnt[i];
if (mx[a[i]^1] > b[i]) ans--;
mx[a[i]] = max (mx[a[i]], b[i]);
}
printf ("%d\n", ans);
} return 0;
}
打表+数学 1003 GTW likes function
题意:中文题面
分析:打表才能看出来是 n + x + 1,然后可以直接套模版计算了。严格证明看官方题解。
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std; typedef long long ll; ll euler(ll x) {
ll ret = x, t = x;
for (int i=2; i*i<=x; ++i) {
if (t % i == 0) {
ret = ret / i * (i - 1);
while (t % i == 0) t /= i;
}
}
if (t > 1) ret = ret / t * (t - 1);
return ret;
} ll euler2(ll x) {
ll ret = 1, i = 2;
for (; i*i<=x; ++i) {
if (x % i == 0) {
x /= i;
ret *= (i - 1);
while (x % i == 0) {
x /= i; ret *= i;
}
}
}
if (x > 1) ret *= (x - 1);
return ret;
} ll _pow(ll x, int n) {
ll ret = 1;
for (int i=1; i<=n; ++i) {
ret *= x;
}
return ret;
} ll comb(int n, int m) {
ll ret = 1;
for (int i=1; i<=m; ++i) {
ret = ret * n; n--;
}
ll ret2 = 1, t = m;
for (int i=1; i<=m; ++i) {
ret2 = ret2 * t; t--;
}
return ret / ret2;
} ll fun(int x) {
ll ret = 0;
for (int i=0; i<=x; ++i) {
ret += _pow (-1, i) * _pow (2, 2 * x - 2 * i) * comb (2 * x - i + 1, i);
}
return ret;
} int main(void) {
/*ll f = fun (10);
printf ("i: %d f: %d\n", 0, f);
for (int i=1; i<=10; ++i) {
f = fun (f);
printf ("i: %d f: %d\n", i, f);
}*/
ll n, x;
while (scanf ("%I64d%I64d", &n, &x) == 2) {
printf ("%I64d\n", euler2 (n + x + 1));
} return 0;
}
BestCoder Round #66 (div.2)的更多相关文章
- BestCoder Round #66 (div.2)B GTW likes gt
思路:一个O(n)O(n)的做法.我们发现b_1,b_2,...,b_xb1,b2,...,bx都加11就相当于b_{x+1},b_{x+2},...,b_nbx+1,bx+ ...
- HDU5597/BestCoder Round #66 (div.2) GTW likes function 打表欧拉函数
GTW likes function Memory Limit: 131072/131072 K (Java/Others) 问题描述 现在给出下列两个定义: f(x)=f_{0}(x)=\ ...
- HDU5596/BestCoder Round #66 (div.2) 二分BIT/贪心
GTW likes gt Memory Limit: 131072/131072 K (Java/Others) 问题描述 从前,有nn只萌萌的GT,他们分成了两组在一起玩游戏.他们会排列成一排 ...
- HDU 5596/BestCoder Round #66 (div.2) GTW likes math 签到
GTW likes math Memory Limit: 131072/131072 K (Java/Others) 问题描述 某一天,GTW听了数学特级教师金龙鱼的课之后,开始做数学<从自主 ...
- BestCoder Round #66 (div.2) hdu5592
GTW likes math Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
- BestCoder Round #66 (div.2) 1002
GTW likes gt Accepts: 132 Submissions: 772 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...
- hdu 5636 搜索 BestCoder Round #74 (div.2)
Shortest Path Accepts: 40 Submissions: 610 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: ...
- hdu5634 BestCoder Round #73 (div.1)
Rikka with Phi Accepts: 5 Submissions: 66 Time Limit: 16000/8000 MS (Java/Others) Memory Limit: ...
- BestCoder Round #69 (div.2) Baby Ming and Weight lifting(hdu 5610)
Baby Ming and Weight lifting Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K ( ...
随机推荐
- Java代码简化神器-Lombok
一.背景 前段时间在开源社区中发现了一个比较牛逼的简化Java代码的神器-Lombok,接着自己写了demo进行测试和练习,感觉真的很不错,特此分享给需要的小伙伴们~ 二.开发之前的准备 1.lomb ...
- 选择题(codevs 2919)
2919 选择题 时间限制: 1 s 空间限制: 16000 KB 题目等级 : 黄金 Gold 题解 查看运行结果 题目描述 Description 某同学考试,在N*M的答题卡上写 ...
- C语言中一个替换 strcpy的极好的方法
在C语言中有个方法:strcpy() 使用时经常容易内存申请不足,或是没有申请内存导致,复制的时候报错,我新写了一个方法,弥补这个缺陷 char *strcpy1(char *strDes, char ...
- 再来一发!DB2 应用程序如何从数据库取数据 Fetch
The FETCH statement positions a cursor on the next row of its result table and assigns the values of ...
- NYOJ题目64鸡兔同笼
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAsAAAAIZCAIAAAAnfB5fAAAgAElEQVR4nO3dO1LjygIG4LsJchZC7I ...
- PHP魔术方法在框架中的应用
class usermodel{ protected $email='user@163.com'; protected $data=array(); public function __set($k, ...
- ARPPING
http://www.tuicool.com/articles/M7B3umj http://lixcto.blog.51cto.com/4834175/1571838/
- Unity依赖注入使用
构造器注入(Constructor Injection):IoC容器会智能地选择选择和调用适合的构造函数以创建依赖的对象.如果被选择的构造函数具有相应的参数,IoC容器在调用构造函数之前会自定义创建相 ...
- siblings 使用
//$(object).siblings().each(function () { // $(this).find("img").attr("class", & ...
- 【翻译十二】java-并发之活性
A concurrent application's ability to execute in a timely manner is known as its liveness. This sect ...