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 ( ...
随机推荐
- supersr--NSURLSessionConfiguration-下载进度
//// ViewController.m// 下载进度 // // Created by Super on 14/7/4. // Copyright (c) 2014年 iOS. All r ...
- supersr--控制器的生命周期:
调用顺序为 1 init函数(init;initWithFrame;initWithCoder;等)--初始化 2 awakeFromNib--在loadView之前的工作放在这里 3 viewDid ...
- 3ds max不显示网格,转换为可编辑面片
按G就消失了,快捷键 F3/F4切换线框和面片模式的显示
- jvm分析
是什么 jps 查看所有的jvm进程,包括进程ID,进程启动的路径等等. jstack 观察jvm中当前所有线程的运行情况和线程当前状态. 系统崩溃了?如果java程序崩溃生成core文件,j ...
- js判断是否为ie6以外的浏览器,若是,则调用相应脚本
if(navigator.userAgent.indexOf("MSIE 6.0") < 0) { //相应JavaScript脚本}
- UISegmentedControl
1. NSArray *segmentedArray = [[NSArray alloc]initWithObjects:@"1",@"2",@"3& ...
- MVC4 自定义错误页面(三)
一.概述 MVC4框架自带了定义错误页,该页面位于Shared/Error,该页面能够显示系统未能捕获的异常,如何才能使用该页面: 二.使用步骤: 1.配置WebConfig文件,在System.We ...
- AspectFill VS. AspectFit
从去年10月进入公司,到现在差不多忙碌了3个月,期间几乎所有精力和时间都花在了公司的项目上,有很多工作学习的心得一直没有总结,趁周末无事就来使这写一写. 除了刚进公司的那一个月是做一些修修补补的工作, ...
- NuGet安装和使用
1. NuGet是什么? NuGet is a Visual Studio 2010 extension that makes it easy to add, remove, and update l ...
- outlook备份及恢复
outlook备份及恢复 Reference: http://wenku.baidu.com/link?url=2gtDkCSDoPdnfx3Ungd6on9wdhUTWgbO_vmmKLv1i4df ...