2018

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 507    Accepted Submission(s): 263

Problem Description

Given a,b,c,d, find out the number of pairs of integers (x,y) where a≤x≤b,c≤y≤d and x⋅y is a multiple of 2018.

Input

The input consists of several test cases and is terminated by end-of-file.

Each test case contains four integers a,b,c,d.

Output

For each test case, print an integer which denotes the result.
## Constraint
* 1≤a≤b≤109,1≤c≤d≤109
* The number of tests cases does not exceed 104.

Sample Input

1 2 1 2018

1 2018 1 2018

1 1000000000 1 1000000000

Sample Output

3

6051

1485883320325200

思路:

1.若x是偶数:1)若x是1009的倍数,则y可为[c,d]中任意数; 2)若x不是1009的倍数,则y必定为[c,d]中1009的倍数
2.若x是奇数:1)若x是1009的倍数,则y必定为[c,d]中2的倍数; 2)若x不是1009的倍数,则y必定为[c,d]中2018的倍数

AC代码:

#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<queue>
#include<utility>
#define ll long long
using namespace std;
const int maxn = 1e5+; int main(int argc, char const *argv[])
{
ll a,b,c,d;
while(~scanf("%lld %lld %lld %lld",&a,&b,&c,&d))
{
ll s1 = b-a+;
ll s2 = d-c+;
ll s1_odd = b/-(a-)/;
ll s1_1009 = b/-(a-)/; ll x1=(b/-(a-)/)*s2;
ll x2=(s1_odd-(b/-(a-)/))*(d/-(c-)/);
ll x3=(s1_1009-(b/-(a-)/))*(d/-(c-)/);
ll x4=((s1-s1_odd)-(s1_1009-(b/-(a-)/)))*(d/-(c-)/);
printf("%lld\n",x1+x2+x3+x4);
}
return ;
}

最新文章

  1. Android-修改TabWidget字体大小颜色及对齐
  2. 后移动互联网时代:到底还要不要开发一个App?
  3. [转]Raspberry Pi树莓派无线网卡配置[多重方法备选]
  4. 区别和详解:jQuery extend()和jQuery.fn.extend()
  5. CentOS找回root密码
  6. 【struts2】Result和ResultType
  7. 64位ubuntu下重新编译hadoop2.2流水账
  8. iOS开发之网络数据解析(一)--JSON解析简介
  9. ASP.NET 系列:RBAC权限设计
  10. Qt中使用Firebird 和 Firebird Embedded
  11. Oracle中NULL值与索引
  12. Does not contain a valid host;port authority解决方法
  13. Akka(21): Stream:实时操控:人为中断-KillSwitch
  14. DHCP的主要知识点
  15. ES6基础语法
  16. 记录一下idea自动生成Entity
  17. 【GMT43智能液晶模块】例程六:WWDG看门狗实验——复位ARM
  18. spring mvc MultipartFile 上传文件 当文件较小时(10k) ,无法上传成功 。
  19. 关于Golang中database/sql包的学习
  20. 用Navicat Premium 操作MySQL数据库

热门文章

  1. 再探motan
  2. 个人开源Git地址
  3. Java中的IO流(四)
  4. redis存储数据的时候
  5. DML-删除
  6. SQL 二
  7. UICollectionView的水平流水布局自定义layout
  8. 复习宝典之Redis
  9. Docker之centos 简单安装
  10. UNIX故障--sun m4000服务器故障硬盘更换案例