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;
}

  

 

转载于:https://www.cnblogs.com/Running-Time/p/5042477.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值