Four tuples(2018山東省賽 F)

2022-07-02 02:39:11 字數 1259 閱讀 4188

時間限制: 10 sec  記憶體限制: 128 mb

given l1,r1,l2,r2,l3,r3,l4,r4, please count the number of four-tuples (x1,x2,x3,x4) such that li≤ xi≤ ri and x1≠x2,x2≠x3,x3≠x4,x4≠x1. the answer should modulo 10^9+7 before output.

the input consists of several test cases. the first line gives the number of test cases, t(1≤ t≤ 10^6).

for each test case, the input contains one line with 8 integers l1,r1,l2, r2, l3,r3,l4,r4(1≤ li≤ ri≤ 10^9)

for each test case, output one line containing one integer, representing the answer.

1

1 1 2 2 3 3 4 4

1

題意很簡單,這是一道容斥定理題,其實也挺簡單的,,,(然而自己菜,容斥公式忘了,翻書找到的容斥竟然是有錯的,然後最後一直debug....也沒發現問題,最後隊友說交一發試試,沒想到返回yes)

吃驚!!!!!

設事件a為x1!=x2 ,事件b 為x2!=x3 ,事件c 為 x3!=x4 事件d 為 x4!=x1

問題要求:|a∩b∩c∩d|

可以轉換成|u|-|a'∪b'∪c'∪d'|

即求 |a'∪b'∪c'∪d'| 就行,容斥定理

c++ code:

#include using

namespace

std;

const

int mod=1e9+7

;typedef

long

long

ll;ll query(ll l1,ll r1,ll l2,ll r2)

ll query2(ll l1,ll r1,ll l2,ll r2,ll l3,ll r3)

ll query3(ll l1,ll r1,ll l2,ll r2,ll l3,ll r3,ll l4,ll r4)

intmain()

return0;

}

總結山東省賽2015

省賽總結 剛開始,暴力破解試題袋,三個人找水題做,我看的h,hms看a,zzh看的c,看出是做過的類似的博弈論,直接敲wa了,查bug沒有,加了個return 0,過了2y,這時再看榜,a題c題已經有許多過掉的,我和hms看a題,看完覺得簡單,就是個結構體排序,直接敲,過一遍樣例就交,結果wa,開始...

19山東省賽 K Happy Equation

當時省賽花了很長時間在這道題上,最後也沒做出來,特別傷心啊啊啊啊賽後仔細研究了一下,怎麼說呢,學到了很多,也認識到了自己的不足,唉 little sub has just received an equation,which is shown below,as his birthday gift.a...

2019山東省賽補題

a題 題解 a題注意看清題目每月三十天每週五天很關鍵,因為每月星期幾是固定的。include define ll long long using namespace std const ll nl 1e5 5 ll a nl ll b nl ll c nl int main else if s tu...