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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

Countries

發(fā)布時間:2024/8/23 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Countries 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

描述

There are two antagonistic countries, country A and country B. They are in a war, and keep launching missiles towards each other.

It is known that country A will launch N missiles. The i-th missile will be launched at time Tai. It flies uniformly and take time Taci from one country to the other. Its damage capability is Dai.

It is known that country B will launch M missiles. The i-th missile will be launched at time Tbi.

It flies uniformly and takes time Tbci?from one country to the other. Its damage capability is Dbi.

Both of the countries can activate their own defending system.

The defending system of country A can last for time TA, while The defending system of country B can last for time TB.

When the defending system is activated, all missiles reaching the country will turn around and fly back at the same speed as they come.

At other time, the missiles reaching the country will do damages to the country.
(Note that the defending system is still considered active at the exact moment it fails)

Country B will activate its defending system at time X.

When is the best time for country A to activate its defending system? Please calculate the minimal damage country A will suffer.

輸入

There are no more than 50 test cases.

For each test case:

The first line contains two integers TA?and TB, indicating the lasting time of the defending system of two countries.

The second line contains one integer X, indicating the time that country B will active its defending system.

The third line contains two integers N and M, indicating the number of missiles country A and country B will launch.

Then N lines follow. Each line contains three integers Tai, Taci?and Dai, indicating the launching time, flying time and damage capability of the i-th missiles country A launches.

Then M lines follow. Each line contains three integers Tbi, Tbci?and Dbi, indicating the launching time, flying time and damage capability of the i-th missiles country B launches.

0 <= TA, TB, X, Tai, Tbi<= 100000000

1 <= Taci, Tbci?<= 100000000

0 <= N, M <= 10000

1 <= Dai, Dbi?<= 10000

輸出

For each test case, output the minimal damage country A will suffer.

提示

In the first case, country A should active its defending system at time 3.

Time 1: the missile is launched by country A.

Time 2: the missile reaches country B, and country B actives its defending system, then the missile turns around.

Time 3: the missile reaches country A, and country A actives its defending system, then the missile turn around.

Time 4: the missile reaches country B and turns around.

Time 5: the missile reaches country A and turns around.

Time 6: the missile reaches country B, causes damages to country B.


樣例輸入
2 2 2 1 0 1 1 10 4 5 3 2 2 1 2 10 1 5 7 1 3 2 0 4 8
樣例輸出
0

17

#include <cmath> #include <ctime> #include <cctype> #include <cstdio> #include <cstring> #include <cstdlib> #include <cassert> #include <set> #include <map> #include <stack> #include <queue> #include <vector> #include <bitset> #include <complex> #include <iostream> #include <algorithm> #define rep(i,s,t) for(register LL i=s,_t=t;i<_t;++i) #define per(i,s,t) for(register LL i=t-1,_s=s;i>=_s;--i) using namespace std; #define LL long long const LL mod=(LL)1e9+7,inf=0x7fffffff; const LL INF=1ll<<60;const LL P=31525197391593473,r=3;void mod_add(LL &a,LL b){if((a+=b)>=P)a-=P; } void mod_minus(LL &a,LL b){if((a-=b)<0)a+=P; } LL mul(LL x,LL y,LL z){ return (x*y - (LL)(x/(long double)z*y+1e-3)*z+z)%z; }LL fast_mod_pow(LL a,LL b){LL res=1;for(;b;b>>=1,a=mul(a,a,P))if(b&1)res=mul(res,a,P);return res; }inline LL calc_inv(LL x){return fast_mod_pow(x,P-2); }const LL N=(1<<18)+5; LL rev[N],A[N],B[N],C[N];void DFT(LL *arr,LL n,bool flag){rep(i,0,n)if(i<rev[i])swap(arr[i],arr[rev[i]]);for(LL m=2;m<=n;m<<=1){LL g=fast_mod_pow(r,(P-1)/m);if(flag)g=calc_inv(g);for(LL i=0;i<n;i+=m){LL cur=1;rep(j,0,m>>1){LL x=arr[i+j],y=mul(cur,arr[i+j+(m>>1)],P);mod_add(arr[i+j]=x,y);mod_minus(arr[i+j+(m>>1)]=x,y);cur=mul(cur,g,P);}}} } void NTT(LL n,LL m){LL _n,S;for(_n=1,S=0;_n<n+m;_n<<=1,++S);rep(i,1,_n)rev[i]=(rev[i>>1]>>1)|((i&1)<<S-1);rep(i,n,_n)A[i]=0;rep(i,m,_n)B[i]=0;DFT(A,_n,false);DFT(B,_n,false);rep(i,0,_n)C[i]=mul(A[i],B[i],P);DFT(C,_n,true);LL inv=calc_inv(_n);rep(i,0,_n)C[i]=mul(C[i],inv,P); }int main() {LL T;scanf("%lld",&T); LL n; while(T-- && ~scanf("%lld",&n)){ long long ans = 0; for(LL i = 0;i < n;i++){scanf("%lld",&A[i]);ans += 1ll * A[i] * A[i]; } for(LL i = 0;i < n;i++){scanf("%lld",&B[i]);ans += 1ll * B[i] * B[i]; } for(LL i = 0;i < n;i++) A[i+n] = A[i];reverse(B,B+n); NTT(n*2,n); ans -= *max_element(C+n,C+n*2 + 1) * 2; printf("%lld\n",ans); }return 0; }

總結

以上是生活随笔為你收集整理的Countries的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 女性裸体瑜伽无遮挡 | 美女草逼视频 | 午夜寂寞影院在线观看 | www.av在线播放 | 久久视频免费 | 日韩经典一区二区 | va视频在线 | 免费看一区二区三区 | 久久激情久久 | wwwxxxx国产 | 韩国三级中文字幕hd浴缸戏 | 国产亚洲精品精品精品 | 在线色网站 | 日韩毛片网 | 一区二区日韩欧美 | 夜夜操影院 | 日产av在线| 国产成人无码www免费视频播放 | 青青草手机视频 | 成人福利在线播放 | 国产亚洲精品久久777777 | 激情国产视频 | 精品视频在线一区二区 | 超污网站在线观看 | 尤物av无码色av无码 | 最新中文字幕一区 | 国产乡下妇女做爰毛片 | 欧美被狂躁喷白浆精品 | 亚洲精品免费网站 | 国产精品美女久久 | ass亚洲尤物裸体pics | 久久婷婷综合色 | 884aa四虎影成人精品一区 | 欧美成人免费高清视频 | 操亚洲| 亚洲一区二区小说 | 亚洲视频在线免费观看 | 国产又黄又大又爽 | 秘密基地免费观看完整版中文 | 成人区人妻精品一区二区网站 | 日本久久一区二区 | 久久久久免费精品视频 | 成人在线观看免费网站 | 日韩欧美黄色大片 | 女同av在线播放 | 亚洲二区在线 | 最新国产视频 | 国产男男gay体育生网站 | 五月天婷婷在线观看 | 日本aⅴ在线观看 | 夜夜操影视| 年代下乡啪啪h文 | 亚洲天堂免费 | 久在线视频 | 国产一区视频在线播放 | 国产丰满大乳奶水在线视频 | sm调教羞耻姿势图片 | 色屁屁ts人妖系列二区 | 色午夜婷婷 | 国产一区二区三区在线观看免费 | 永久免费看mv网站入口亚洲 | 美女在线观看视频 | 午夜伦伦电影理论片费看 | 亚洲插 | 中文字幕二 | 一级黄色大片网站 | 亚洲ⅴ国产v天堂a无码二区 | 成人免费版 | 国产又大又黑又粗免费视频 | 一区二区三区美女视频 | 亚洲一区不卡 | 黄色成人在线视频 | 一区二区三区免费观看视频 | 国产视频一区二区在线观看 | 欧美成本人视频 | re久久| 欧洲金发美女大战黑人 | 免费无码不卡视频在线观看 | 91亚洲精品久久久蜜桃借种 | 5d肉蒲团之性战奶水 | 欧美黑人一级爽快片淫片高清 | 色哟哟在线免费观看 | 中文字幕无码日韩专区免费 | 欧美一级视频在线观看 | 国产亚洲欧洲 | 在线免费观看污网站 | 国产精品你懂的 | 九一国产视频 | 日本少妇裸体做爰 | 亚洲精品高清在线 | 欧美午夜精品一区 | 亚洲欧洲在线看 | 国产一区第一页 | 黑人专干日本人xxxx | 国产91久久精品一区二区 | 欧美性做爰免费观看 | 人妻无码中文久久久久专区 | 91精品网站 | 午夜在线播放 |