Codeforces Round #232 (Div. 2)渣渣也写。

A. On Segment's Own Points

题意大概是嗮衣服吧,然后他又不喜欢跟别人嗮一起,每个人可以嗮[li,rl]这个区间,所以会有重复,问他最长嗮多少。注意,他是第一个输入!!!看英文题就是烦,看了long long ago。

由于数据又不大,所以直接标记别人的就可以了。标前不标后。

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <list>
#include <vector>
using namespace std;
//#define DEBUG
int main()
{
#ifdef DEBUG
	freopen("cin.txt", "r", stdin);
	freopen("cout.txt", "w", stdout);
#endif
	int f[110],n,a,b,l,r,i;
	memset(f,0,sizeof(f));
	scanf("%d",&n);
	scanf("%d%d",&a,&b);
	n--;
	while (n--)
	{
		scanf("%d%d",&l,&r);
		for (i=l;i<r;i++)
			f[i]=1;
	}
	int t=0;
	for (i=a;i<b;i++)
		if (f[i]==0) t++;
	printf("%d\n",t);
	return 0;
}

B. On Corruption and Numbers


题意:给出一个n面额的需求,问能从[l,r]之间取出任意金额,任意枚数,能否等于n。

最开始我题意理解错了,以为就l和r两枚金额的,结果...

后来知道是[l,r]这个区间,于是定义k=n/l,再判断k*r是否大于n。大于n则ok,否则则no。

但是计算的时候才发现k*r有可能超出int范围,结果死活不AC,再加一个条件r只要大于两倍l就绝对ok,就AC了!坑。

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <list>
#include <vector>
using namespace std;
//#define DEBUG
void yes()
{
	printf("Yes\n");
}
void no()
{
	printf("No\n");
}
int main()
{
#ifdef DEBUG
	freopen("cin.txt", "r", stdin);
	freopen("cout.txt", "w", stdout);
#endif
	int t,a,n,b;
	scanf("%d",&t);
	while (t--)
	{
		scanf("%d%d%d",&n,&a,&b);
		if ( (n<a)  && (n<b) ) 
		{
			no();
			continue;
		}
		int k=n/a;
		if ((b>=2*a-1) || (a<=n && b>=n) || k*b>=n) yes();
		else no();
	}
	return 0;
}


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值