日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Four-tuples (2018山东省省赛 容斥定理)

發(fā)布時間:2024/10/14 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Four-tuples (2018山东省省赛 容斥定理) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

感謝大佬的博客:

https://blog.csdn.net/qq_41021816/article/details/80328475

開始的時候不知道如何求滿足性質(zhì)pi的元素個數(shù),知道參考了上面的大佬的博客才明白。

還有就是要知道這中取模的,如果ans要減的話,在減之后必須要加上mod在取模才行。

代碼:

#include <iostream> ? ??
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
/* 剛開始打算這樣做,實在是太傻了。
void fun(int i)
{
?? ?if(arrl[i]>arrr[ (i+1)%4 ])
?? ??? ?flag[i]=0;
?? ?else if( arrl[i]>=arrl[ (i+1)%4 ]&&arrr[ (i+1)%4 ]>=arrl[i]&&arrr[ (i+1)%4 ]<=arrr[i] )
?? ?{
?? ??? ?flag[i]=arrr[ (i+1)%4 ]-arrl[i]+1;
?? ??? ?temp[i][0]=arrl[i],temp[i][1]=arrr[ (i+1)%4 ];
?? ?}?? ?
?? ?else if( arrl[ (i+1)%4 ]<=arrl[i]&&arrr[ (i+1)%4 ]>=arrr[i] )
?? ?{
?? ??? ?flag[i]=arrr[i]-arrl[i]+1;
?? ??? ?temp[i][0]=arrl[i],temp[i][1]=arrr[i];
?? ?}
?? ?else if( arrl[i]<=arrl[ ?(i+1)%4 ]&&arrr[i]>=arrr[ (i+1)%4 ] )
?? ?{
?? ??? ?flag[i]=arrr[ (i+1)%4 ]-arrl[(i+1)%4]+1;
?? ??? ?temp[i][0]=arrl[(i+1)%4]+1,temp[i][1]=arrr[ (i+1)%4 ];
?? ?}
?? ?else if( arrl[ (i+1)%4 ]>=arrl[i]&&arrl[ (i+1)%4 ] <=arrr[i]&&arrr[ (i+1)%4 ]>=arrr[i] )
?? ?{
?? ??? ?flag[i]=arrr[i]-arrl[ (i+1)%4 ]+1;
?? ??? ?temp[i][0]=arrl[ (i+1)%4 ],temp[i][1]=arrr[i];
?? ?}
?? ?else if(arrl[ (i+1)%4 ]>arrr[i] )
?? ??? ?flag[i]=0;?? ??? ?
}*/?

int main()
{
?? ?int T;
?? ?scanf("%d",&T);
?? ?ll l1,r1,l2,r2,l3,r3,l4,r4;
? ? ll acl,acr;
? ? ll accl,accr;
?? ?ll flag[10]; ??
?? ?ll ans=0;
?? ?while(T--)?? ??? ??? ?
?? ?{
?? ??? ?scanf("%lld %lld %lld %lld %lld %lld %lld %lld",&l1,&r1,&l2,&r2,&l3,&r3,&l4,&r4);
?? ??? ?ans=(r1-l1+1)%mod*(r2-l2+1)%mod*(r3-l3+1)%mod*(r4-l4+1)%mod; ? //為零的時候應該是不存在的。
?? ??? ?ll temp;
?? ??? ?//x1==x2
?? ??? ?acl=max( l1,l2 );
?? ??? ?acr=min(r1,r2);
?? ??? ?temp=acr-acl+1;
?? ??? ?ll temp12=temp;
?? ??? ?if(acr>=acl) ? ?//做題做多了就行了。?
?? ??? ??? ?ans=( ans-( temp*(r3-l3+1)%mod*(r4-l4+1)%mod)+mod )%mod;?? ??
?? ??? ?//x2==x3;
?? ??? ?acl=max(l2,l3);
?? ??? ?acr=min(r2,r3);
?? ??? ?temp=acr-acl+1;
?? ??? ?ll temp23=temp;
?? ??? ?if(temp>0)
?? ??? ??? ?ans=(ans-( temp*(r1-l1+1)%mod*(r4-l4+1)%mod) + mod )%mod;
?? ??? ?//x3==x4;
?? ??? ?acl=max(l4,l3);
?? ??? ?acr=min(r4,r3);
?? ??? ?temp=acr-acl+1;
?? ??? ?ll temp34=temp;
?? ??? ?if(temp>0)
?? ??? ??? ?ans=(ans-( temp*(r1-l1+1)%mod*(r2-l2+1)%mod) +mod)%mod;
?? ??? ?//x4==x1;
?? ??? ?acl=max(l1,l4);
?? ??? ?acr=min(r1,r4);
?? ??? ?temp=acr-acl+1;
?? ??? ?ll temp41=temp;
?? ??? ?if(temp>0)
?? ??? ??? ?ans=(ans-( temp*(r2-l2+1)%mod*(r3-l3+1)%mod)+mod )%mod;
?? ??? ?//x1==x2&&x2==x3;
?? ??? ?acl=max( l1,l2 );
?? ??? ?acr=min(r1,r2);
?? ??? ?temp=acr-acl+1; ? ? ?
?? ??? ?if(temp>0)
?? ??? ?{
?? ??? ??? ?accl=max( acl,l3 );
?? ??? ??? ?accr=min( acr,r3 );
?? ??? ??? ?temp=accr-accl+1;
?? ??? ??? ?if(temp>0)?? ??? ??? ?//最后的時候還要進行取與嗎,?
?? ??? ??? ??? ?ans=(ans%mod+( temp*(r4-l4+1)%mod )%mod )%mod;?? ?
?? ??? ?}
?? ??? ?//x1==x2&&x3==x4;?
?? ??? ?acl=max( l1,l2 );?? ?
?? ??? ?acr=min(r1,r2); ? ? ?? ? ? ? ? ?
?? ??? ?temp=acr-acl+1;
?? ??? ?if(temp>0&&temp34>0 )
?? ??? ?{
?? ??? ??? ? ans=(ans%mod+temp%mod*(temp34%mod)%mod)%mod;?? ?
?? ??? ?}
?? ??? ?//x1==x2&&x4==x1;?? ?//使用簡便方法來實現(xiàn)吧。?
?? ??? ?acl=max( l1,l2 );
?? ??? ?acr=min(r1,r2);
?? ??? ?temp=acr-acl+1; ? ? ?
?? ??? ?if(temp>0)
?? ??? ?{
?? ??? ??? ?accl=max( acl,l4 );
?? ??? ??? ?accr=min( acr,r4 );
?? ??? ??? ?temp=accr-accl+1;
?? ??? ??? ?if(temp>0)?? ??? ??? ?//最后的時候還要進行取與嗎,?
?? ??? ??? ??? ?ans=(ans%mod+( temp%mod*(r3-l3+1)%mod )%mod )%mod;?? ?
?? ??? ?}
?? ??? ?//x2==x3&&x3==x4;
?? ??? ?acl=max( l3,l2 );
?? ??? ?acr=min(r3,r2);
?? ??? ?temp=acr-acl+1; ? ? ?
?? ??? ?if(temp>0)
?? ??? ?{
?? ??? ??? ?accl=max( acl,l4 );
?? ??? ??? ?accr=min( acr,r4 );
?? ??? ??? ?temp=accr-accl+1;
?? ??? ??? ?if(temp>0)?? ??? ??? ?//最后的時候還要進行取與嗎,?
?? ??? ??? ??? ?ans=(ans%mod+( temp%mod*(r1-l1+1)%mod )%mod )%mod;?? ?
?? ??? ?}
?? ??? ?//x2==x3&&x4==x1;
?? ??? ?if(temp23>0&&temp41>0)
?? ??? ?{
?? ??? ??? ?ans=(ans%mod+temp23%mod*(temp41%mod)%mod)%mod;?? ?
?? ??? ?}?
?? ??? ?//x3==x4&&x4==x1;
?? ??? ?acl=max( l3,l4 );
?? ??? ?acr=min( r3,r4 );
?? ??? ?temp=acr-acl+1; ? ? ?
?? ??? ?if(temp>0)?? ??? ? ? ? ? ? ?
?? ??? ?{
?? ??? ??? ?accl=max( acl,l1 );
?? ??? ??? ?accr=min( acr,r1 );
?? ??? ??? ?temp=accr-accl+1;
?? ??? ??? ?if(temp>0)?? ??? ??? ?//最后的時候還要進行取與嗎,?
?? ??? ??? ??? ?ans=(ans%mod+( temp%mod*(r2-l2+1)%mod )%mod )%mod;?? ?
?? ??? ?}
?? ??? ?//都相等的情況。?
?? ??? ?acl=max(max( l1,l2 ),max(l3,l4) );
?? ??? ?acr=min( min( r1,r2 ),min(r3,r4)); ? ? ??
?? ??? ?temp=acr-acl+1;
?? ??? ?if(temp>0) ? ?? ??? ??? ?//情況有幾種。?
?? ??? ?{
?? ??? ??? ?//temp=(temp*3)%mod;
?? ??? ??? ?ans=(ans%mod-temp*3%mod+ mod)%mod; ? ? ?? ?
?? ??? ?}
?? ??? ?printf("%lld\n",ans);?? ??? ??? ??
?? ?}
?? ?return 0;?? ?
}

?

總結

以上是生活随笔為你收集整理的Four-tuples (2018山东省省赛 容斥定理)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 美女毛片网站 | 国产喷水视频 | 中国女人做爰视频 | 少妇一夜三次一区二区 | 亚洲91精品 | 手机天堂av | 中文字幕一区二区三区乱码 | 嫩草大剧院 | 日本美女毛片 | 国产精品一区二区av日韩在线 | 国产在线观看免费 | 亚洲欧美日韩中文字幕在线观看 | 一二区在线视频 | 成人一区二区在线 | 日本网站在线 | 一级做a爱片 | 成人av一区 | 国产精品乱码 | 国产无遮挡又黄又爽免费网站 | 在线观看国产一区二区 | 九九久久精品视频 | 成熟丰满熟妇高潮xxxxx视频 | 国产麻豆一区二区三区在线观看 | 一级小毛片 | 99精品视频在线观看免费 | 亚洲乱码视频在线观看 | 日本伊人色 | 久久午夜夜伦鲁鲁片无码免费 | 黄瓜污视频 | 在线播放一区 | 一二区在线观看 | 日本三级在线视频 | 大学生三级中国dvd 日韩欧美一区二区区 | 久久精品视频播放 | 天堂va蜜桃一区 | 亚洲女人视频 | 亚洲国产精品久久久久爰色欲 | 91色综合| 国产精品久久久久久久久久妞妞 | 日韩av电影手机在线观看 | 超碰碰97| 少妇熟女一区二区 | 久草国产视频 | 国产看黄网站 | 98久久| 亚日韩一区 | 国产初高中真实精品视频 | 少妇天堂网 | 超黄网站在线观看 | 91精品国产一区二区 | 91狠狠干 | www黄色片网站 | 欧美第一页草草影院 | 亚洲国产免费 | 日本欧美激情 | 色妻av| 久久黄色一级片 | 欧美一区二区视频免费观看 | 日韩无码电影 | 丰满大乳露双乳呻吟 | 天天操夜夜骑 | 在线观看亚洲 | 成长快手短视频在线观看 | 黄色小视频在线观看 | 久久久久国产精品视频 | 国产制服91一区二区三区制服 | 久久精品视频一区二区三区 | 性色av一区二区三区在线观看 | 超碰夜夜 | 国产亚洲欧美在线视频 | 操操操免费视频 | 国内自拍xxxx18 | 插插射射 | 九九免费精品视频 | 丰满少妇中文字幕 | 欧美在线观看网站 | 亚洲精品福利在线观看 | 女同毛片一区二区三区 | 一区二区免费看 | 你懂的在线视频网站 | 黑人巨大猛交丰满少妇 | 99热日本 | 丁香花在线影院观看在线播放 | 97超碰国产精品无码蜜芽 | 天堂va欧美ⅴa亚洲va一国产 | 在线观看国产免费av | 久久婷婷国产 | 精品国产av鲁一鲁一区 | 土耳其xxxx性hd极品 | 影音先锋每日资源 | 猛男大粗猛爽h男人味 | 美女张开腿让人桶 | 78m78成人免费网站 | 丝袜五月天 | 午夜电影一区二区 | 女人张开双腿让男人捅 | 亚洲双插 | 中日韩欧美在线观看 | 国产伦理片在线观看 |