hdu 6286 ——2018(CCPC2018-湖南全國邀請賽-重現賽(感謝湘潭大學))
2018
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 500 Accepted Submission(s): 258
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
Source
#include<stdio.h> int main() { long long a,b,c,d; long long a1,b1,a2,b2,a3,b3; long long sum; while(~scanf("%lld%lld%lld%lld",&a,&b,&c,&d)) { sum=0; a1=b/2018-a/2018;//區間一中2018的倍數的個數 if(a%2018==0)//注意!! { a1++; } b1=d/2018-c/2018;//區間二中2018的倍數的個數 if(c%2018==0)//注意!! { b1++; } sum=a1*(d-c+1)+b1*(b-a+1)-a1*b1;//注意!!a1*b1為區間一和區間二中重複 a2=b/1009-a/1009;//區間一中1019的倍數的個數 if(a%1009==0)//注意!! { a2++; } b2=d/1009-c/1009;//區間二中1019的倍數的個數 if(c%1009==0)//注意!! { b2++; } a2=a2-a1;//區間一中1019的倍數的個數-區間一中2018的倍數的個數(即1019的偶數倍數) 可得1019奇數倍數 b2=b2-b1;//區間二中1019的倍數的個數-區間二中2018的倍數的個數(即1019的偶數倍數) 可得1019奇數倍數 a3=b/2-a/2;//區間一中2的倍數的個數 if(a%2==0)//注意!! { a3++; } b3=d/2-c/2;//區間二中2的倍數的個數 if(c%2==0)//注意!! { b3++; } sum=sum+b2*(a3-a1)+a2*(b3-b1);//前面的2018倍數個數+區間一1009的奇數倍個數*區間二2的倍數-2018倍數+區間二1009的奇數倍個數*區間一2的倍數-2018倍數 printf("%lld\n",sum); } return 0; }
相關推薦
hdu 6286 ——2018(CCPC2018-湖南全國邀請賽-重現賽(感謝湘潭大學))
2018 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 500 Accepted Submission(
CCPC2018-湖南全國邀請賽 K 2018
K.2018 題目描述 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. 輸入 The input c
CCPC2018-湖南全國邀請賽 G String Transformation
iostream ear out delet eve 麻煩 感謝 back 所在 String Transformation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Jav
[Training]CCPC2018-湖南全國邀請賽
sequence repl Circul 持久化 本場 sorting long The ans Rank Solved A B C D E F G H I J K --/-- 8/11 O O O . O O O . . O O O: 當場通過 ?:
HDU 5512 Pagodas(2015ACM/ICPC亞洲區瀋陽站-重現賽(感謝東北大學))
Pagodas Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 3502 &nb
2017ACM/ICPC廣西邀請賽-重現賽(感謝廣西大學) B
Do you like painting? Little D doesn’t like painting, especially messy color paintings. Now Little B is painting. To prevent him fr
hdu - 6276,2018CCPC湖南全國邀請賽A題,水題,二分
sum 題意 論文 cto 最大 最大值 nbsp span class 題意: 求H的最大值, H是指存在H篇論文,這H篇被引用的次數都大於等於H次. 思路:題意得, 最多只有N遍論文,所以H的最大值為N, 常識得知H的最小值為0. 所以H的答案在[0,N]之間
HDU 6185 Covering (2017 廣西邀請賽重現賽)(矩陣快速冪)
題意:用1x2或者2x1的地毯去鋪滿4xN的地面。給定N,問方案數. (偶見DFS暴力搜尋前10個結果,學習中,稍後貼上) 解法:推匯出公式後,轉換成矩陣快速冪求解即可. /*dfs
2018.11.25 AMC-ICPC 亞洲區域賽(焦作站)吊銀
11月23日 大清早,跟著wyb的腳步,早起跑過去聽方偉的編譯原理,然鵝一點都沒聽進去,在焦作胡辣湯群裡瘋狂灌水。。。 聽說焦作那邊冷得不行,前一天看天氣預報說那邊已經是2℃了,都快零下了,然鵝學校里正好都沒有厚的衣服。看隊友一個披著黑色大衣,另一個全身裹得嚴嚴實實,而我只有秋裝三件套,外套毛衣T恤衫,我
2017ACM/ICPC亞洲區瀋陽站-重現賽(感謝東北大學)
Little Boxes Problem Description Little boxes on the hillside. Little boxes made of ticky-tacky. Little boxes. Little boxes. Little boxes all
@2015ACM/ICPC亞洲區長春站-重現賽(感謝東北師大) @HDU5534 (Dp,完全揹包)
題目描述 In mathematics, and more specifically in graph theory, a tree is an undirected graph in which any two nodes are connected by exactly
2017ACM-ICPC廣西邀請賽-重現賽
這是在厚林工作室4個人打的一場 騷呢 兩年沒回去了 拿lzy的號打,打的被老劉查水錶了 01 列舉kkk^kkk,k≤15k \leq 15k≤15。 看到我的TTT就知道我是怎麼wa的了。。 #include <bits/stdc++.h>
hdu5512 Pagodas(2015ACM/ICPC亞洲區瀋陽站-重現賽(感謝東北大學) )
n pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the Yuntai Mountain, labelled from 1 to n. However, only two of them (labe
第八屆福建省大學生程式設計競賽-重現賽(感謝承辦方廈門理工學院)
Pro.A Frog fzu2272 雞兔同籠 #include<stdio.h> int main() { int t,a,b; scanf("%d",&am
第十四屆浙江財經大學程式設計競賽重現賽(牛客網)
題意:給定n塊高度的石頭和區間k,問怎樣排序才能使n的所有長度為k的子區間最大值減最小值和最小。思路:貪心,因為距離差值越小則對答案貢獻越小,所以sort一下就好了程式碼:#include<cstdio> #include<cmath> #includ
2013 ACM-ICPC吉林通化全國邀請賽(hdu 4493
D-City Problem Description Luxer is a really bad guy. He destroys everything he met. One day Luxer went to D-city. D-city has N
2013 ACM-ICPC吉林通化全國邀請賽 && HDU 4499 Cannon (搜尋)
Cannon Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others) Total Submis
2013 ACM-ICPC吉林通化全國邀請賽 && HDU 4597 Play Game (博弈 + 區間dp)
Play Game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others) Total Submission(s): 1185 Accepted Submission(
2018杭電多校第一場1011(hdu 6308)
題解:這題主要會超時,不能用string。可以使用sscanf提取字串。 #include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<queue
2018杭電多校第一場1003(hdu 6300)
題解:畫個圖發現只要按橫座標排序,每次取三個點就永遠不會相交 #include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<queue> #