关于csp-j民间数据的疑问
查看原帖
关于csp-j民间数据的疑问
485410
Danny_SCQ楼主2021/10/24 12:48

洛谷上AC了ccf上能过吗

#include<bits/stdc++.h>
using namespace std;
long long first=-10000;
int ans=0;
int main()
{
	//freopen("candy.in","r",stdin);
	//freopen("candy.out","w",stdout);
	long long n,l,r;
	scanf("%lld%lld%lld",&n,&l,&r);
	if(l==r)
	{
		printf("%lld",l%n);
		return 0;
	}
	for(int i=l;i<=r;i++)
	{
		if(i%n==0)
		{
			first=i;
		}
	}
	if(first==-10000)
	{
		printf("%lld",r%n);
		return 0;
	}
	if(l<=first-1)
	{
		printf("%lld",n-1);
		return 0;
	}
	if(r>=first+n-1)
	{
		printf("%lld",n-1);
		return 0;
	}else{
		printf("%lld",r-first);
		return 0;
	}	
	return 0;
}

博客里有思路

2021/10/24 12:48
加载中...