HDU 6286 2018

题目传送门
代码:

#include
using namespace std;

typedef long long LL;

int main(){
	
	int l1,r1,l2,r2;
	while(scanf("%d%d%d%d",&l1,&r1,&l2,&r2)==4){
		
		LL sum=0;
		l1--;l2--;
		int a=r1/2018-l1/2018,b=r2/2018-l2/2018;
		int c=r1/1009-l1/1009,d=r2/1009-l2/1009;
		int e=r1/2-l1/2,f=r2/2-l2/2;
		sum=1LL*a*(r2-l2)+1LL*b*(r1-l1)-1LL*a*b+1LL*(c-a)*(f-b)+1LL*(d-b)*(e-a);
		printf("%lld\n",sum);
 	}
}

你可能感兴趣的:(HDU,ACM)