题意大概是嗮衣服吧,然后他又不喜欢跟别人嗮一起,每个人可以嗮[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;
}