codeforces gym 100952 A B C D E F G H I J

Posted 半根毛线code

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了codeforces gym 100952 A B C D E F G H I J相关的知识,希望对你有一定的参考价值。

A

 1 #include <iostream>
 2 #include<cstdio>
 3 #include<cmath>
 4 #include<cstring>
 5 #include<algorithm>
 6 #include<map>
 7 #include<queue>
 8 #include<stack>
 9 #include<vector>
10 #include<set>
11 using namespace std;
12 #define PI acos(-1.0)
13 typedef long long ll;
14 typedef pair<int,int> P;
15 const int maxn=1e5+100,maxm=1e5+100,inf=0x3f3f3f3f,mod=1e9+7;
16 const ll INF=1e13+7;
17 priority_queue<P,vector<P>,greater<P> >que;
18 struct edge
19 {
20     int from,to;
21     int cost;
22 };
23 int main()
24 {
25     int T;
26     int h1,h2,m1,m2,s1,s2;
27     scanf("%d",&T);
28     while(T--)
29     {
30         scanf("%d%d%d%d%d%d",&h1,&m1,&s1,&h2,&m2,&s2);
31         int sign=0;
32         if(h1<h2) sign=1;
33         else if(h1>h2) sign=2;
34         else
35         {
36             if(m1<m2) sign=1;
37             else if(m1>m2) sign=2;
38             else
39             {
40                 if(s1<s2) sign=1;
41                 else if(s1>s2) sign=2;
42             }
43         }
44         if(sign==1) cout<<"Player1"<<endl;
45         else if(sign==2) cout<<"Player2"<<endl;
46         else cout<<"Tie"<<endl;
47     }
48     return 0;
49 }

 

B

 1 #include <iostream>
 2 #include<cstdio>
 3 #include<cmath>
 4 #include<cstring>
 5 #include<algorithm>
 6 #include<map>
 7 #include<queue>
 8 #include<stack>
 9 #include<vector>
10 #include<set>
11 using namespace std;
12 #define PI acos(-1.0)
13 typedef long long ll;
14 typedef pair<int,int> P;
15 const int maxn=1e5+100,maxm=1e5+100,inf=0x3f3f3f3f,mod=1e9+7;
16 const ll INF=1e13+7;
17 priority_queue<P,vector<P>,greater<P> >que;
18 struct edge
19 {
20     int from,to;
21     int cost;
22 };
23 int main()
24 {
25     int T;
26     scanf("%d",&T);
27     while(T--)
28     {
29         int n,m;
30         scanf("%d%d",&n,&m);
31         int ans=0,cou=0,sign=1;
32         while(true)
33         {
34             if(sign>m) break;
35             cou=cou+sign;
36             ans++;
37             sign*=2;
38             if(cou>=n) break;
39         }
40         ////cout<<cou<<" "<<sign<<endl;
41         if(cou>=n) cout<<ans<<endl;
42         else
43         {
44             ans+=(n-cou)/m;
45             if((n-cou)%m) ans++;
46             cout<<ans<<endl;
47         }
48     }
49     return 0;
50 }

 

C

 1 #include <iostream>
 2 #include<cstdio>
 3 #include<cmath>
 4 #include<cstring>
 5 #include<algorithm>
 6 #include<map>
 7 #include<queue>
 8 #include<stack>
 9 #include<vector>
10 #include<set>
11 using namespace std;
12 #define PI acos(-1.0)
13 typedef long long ll;
14 typedef pair<int,int> P;
15 const int maxn=1e5+100,maxm=1e5+100,inf=0x3f3f3f3f,mod=1e9+7;
16 const ll INF=1e13+7;
17 priority_queue<P,vector<P>,greater<P> >que;
18 struct edge
19 {
20     int from,to;
21     int cost;
22 };
23 char s[maxn];
24 int main()
25 {
26     int T;
27     scanf("%d",&T);
28     while(T--)
29     {
30         int n,p;
31         scanf("%d%d",&n,&p);
32         getchar();
33         for(int i=1; i<=n; i++) scanf("%c",&s[i]);
34         //cout<<s+1<<endl;
35         int ans=0;
36         int l=inf,r=0;
37         for(int i=1; i<=n/2; i++)
38         {
39             if(s[i]!=s[n+1-i])
40             {
41                 l=min(l,i);
42                 r=max(r,i);
43             }
44             if(s[i]<=s[n+1-i]) swap(s[i],s[n+1-i]);
45             ans+=min(s[i]-s[n+1-i],s[n+1-i]+26-s[i]);
46         }
47         if(p>n/2) p=n+1-p;
48         if(l>r) cout<<0<<endl;
49         else
50         printf("%d\n",ans+r-l+min(abs(p-l),abs(p-r)));
51     }
52     return 0;
53 }

 

D

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cmath>
 4 #include <string>
 5 #include <cstring>
 6 #include <algorithm>
 7 #include <queue>
 8 #include <map>
 9 #include <set>
10 #include <stack>
11 #include <sstream>
12 #include <vector>
13 
14 using namespace std;
15 
16 typedef long long ll;
17 /****************************************/
18 const int N = 200000 + 5;
19 const int MOD = (int)1e9 + 7;
20 int F[N], Finv[N], inv[N];//F是阶乘,Finv是逆元的阶乘
21 void init(){
22     inv[1] = 1;
23     for(int i = 2; i < N; i ++){
24         inv[i] = (MOD - MOD / i) * 1ll * inv[MOD % i] % MOD;
25     }
26     F[0] = Finv[0] = 1;
27     for(int i = 1; i < N; i ++){
28         F[i] = F[i-1] * 1ll * i % MOD;
29         Finv[i] = Finv[i-1] * 1ll * inv[i] % MOD;
30     }
31 }
32 int comb(int n, int m){//comb(n, m)就是C(n, m)
33     if(m < 0 || m > n) return 0;
34     return F[n] * 1ll * Finv[n - m] % MOD * Finv[m] % MOD;
35 }
36 int main(){
37     init();
38     int t,n,m,k,d;
39     scanf("%d",&t);
40     while(t--){
41         scanf("%d%d%d%d",&n,&m,&k,&d);
42         int ans=comb(n,m),x,da=0,xiao=0;
43         for(int i=0;i<n;i++){
44             scanf("%d",&x);
45             if(x>=d)da++;
46         }
47         xiao=n-da;
48         for(int i=k-1;i>=0;i--){
49             ans=(ans+MOD-(comb(da,i)*1ll*comb(xiao,m-i))%MOD)%MOD;
50         }
51         printf("%d\n",ans);
52     }
53 }

 

E

 1 #include <iostream>
 2 #include<cstdio>
 3 #include<cmath>
 4 #include<cstring>
 5 #include<algorithm>
 6 #include<map>
 7 #include<queue>
 8 #include<stack>
 9 #include<vector>
10 #include<set>
11 using namespace std;
12 #define PI acos(-1.0)
13 typedef long long ll;
14 typedef pair<int,string> P;
15 const int maxn=1e5+100,maxm=1e5+100,inf=0x3f3f3f3f,mod=1e9+7;
16 const ll INF=1e13+7;
17 priority_queue<P,vector<P>,greater<P> >q;
18 struct edge
19 {
20     int from,to;
21     int cost;
22 };
23 int n,m,t;
24 int pa[20];
25 int flag[20][20];
26 int sign[20][20];
27 int vis[20];
28 int ans=0;
29 void dfs(int x,int y,int cou)
30 {
31     //cout<<x<<" "<<y<<" "<<cou<<endl;
32     if(x>n)
33     {
34         if(cou==t) ans++;
35         return;
36     }
37     for(int k=0; k<=t; k++)
38     {
39         if(k&&vis[k]) continue;
40         if(x-1>=1&&flag[k][sign[x-1][y]]) continue;
41         if(y-1>=1&&flag[k][sign[x][y-1]]) continue;
42         sign[x][y]=k;
43         vis[k]=1;
44         dfs(y==m?x+1:x,y==m?1:y+1,k==0?cou:cou+1);
45         sign[x][y]=0;
46         vis[k]=0;
47     }
48 }
49 int main()
50 {
51     int T;
52     scanf("%d",&T);
53     while(T--)
54     {
55         scanf("%d%d%d",&n,&m,&t);
56         int p;
57         scanf("%d",&p);
58         for(int i=1; i<=t; i++) pa[i]=i;
59         memset(flag,0,sizeof(flag));
60         while(p--)
61         {
62             int a,b;
63             scanf("%d%d",&a,&b);
64             flag[a][b]=flag[b][a]=1;
65         }
66         ans=0;
67         memset(vis,0,sizeof(vis));
68         memset(sign,0,sizeof(sign));
69         dfs(1,1,0);
70         if(ans==0) cout<<"impossible"<<endl;
71         else cout<<ans<<endl;
72     }
73     return 0;
74 }

 

F

  1 #include <iostream>
  2 #include<cstdio>
  3 #include<cmath>
  4 #include<cstring>
  5 #include<algorithm>
  6 #include<map>
  7 #include<queue>
  8 #include<stack>
  9 #include<vector>
 10 #include<set>
 11 using namespace std;
 12 #define PI acos(-1.0)
 13 typedef long long ll;
 14 typedef pair<int,string> P;
 15 const int maxn=1e5+100,maxm=1e5+100,inf=0x3f3f3f3f,mod=1e9+7;
 16 const ll INF=1e13+7;
 17 priority_queue<P,vector<P>,greater<P> >q;
 18 struct edge
 19 {
 20     int from,to;
 21     int cost;
 22 };
 23 map<string,map<string,int> >G;
 24 map<string,int>dist;
 25 struct node
 26 {
 27     string str;
 28     int ss;
 29 }N[305];
 30 bool cmp(struct node aa,struct node bb)
 31 {
 32     if(aa.ss!=bb.ss)
 33     return aa.ss<bb.ss;
 34     else
 35     return aa.str<bb.str;
 36 }
 37 void dij(string s)
 38 {
 39     dist[s]=0;
 40     q.push(P(dist[s],s));
 41     while(!q.empty())
 42     {
 43         P p=q.top();
 44         q.pop();
 45         string u=p.second;
 46         map<string,int> ::iterator it;
 47         for(it=G[u].begin(); it!=G[u].end(); it++)
 48         {
 49             if((*it).second==0) continue;
 50             //cout<<(*it).first<<" "<<(*it).second<<endl;
 51             string v=(*it).first;
 52             if(dist[v]>dist[u]+1)
 53             {
 54                 dist[v]=dist[u]+1;
 55                 q.push(P(dist[v],v));
 56             }
 57         }
 58     }
 59 }
 60 int main()
 61 {
 62     int T;
 63     scanf("%d",&T);
 64     while(T--)
 65     {
 66         int n;
 67         scanf("%d",&n);
 68         string s="Ahmad";
 69         G.clear();
 70         dist.clear();
 71         int jishu=0;
 72         for(int i=1; i<=n; i++)
 73         {
 74             string a,b,c;
 75             cin>>a>>b>>c;
 76             if(dist[a]==0){
 77                 N[jishu++].str=a;
 78                 dist[a]=inf;
 79                 }
 80                   if(dist[b]==0){
 81                 N[jishu++].str=b;
 82                 dist[b]=inf;
 83                 }
 84                   if(dist[c]==0){
 85                 N[jishu++].str=c;
 86                 dist[c]=inf;
 87                 }
 88             G[a][b]=G[b][a]=G[b][c]=G[c][b]=G[a][c]=G[c][a]=1;
 89         }
 90         dij(s);
 91         cout<<jishu<<endl;
 92         for(int i=0;i<jishu;i++)
 93             N[i].ss=dist[N[i].str];
 94         sort(N,N+jishu,cmp);
 95         for(int i=0;i<jishu;i++){
 96              if(N[i].ss>=inf)
 97                 cout<<N[i].str<<" "<<"undefined"<<endl;
 98               else
 99             cout<<N[i].str<<" "<<N[i].ss<<endl;
100             }
101     }
102     return 0;
103 }

 

G

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cmath>
 4 #include <string>
 5 #include <cstring>
 6 #include <algorithm>
 7 #include <queue>
 8 #include <map>
 9 #include <set>
10 #include <stack>
11 #include <sstream>
12 #include <vector>
13 #define PI acos(-1.0)
14 #define N 5e6+10
15 #define M 1000000007
16 #define inf 1e9
17 #define eps 1e-8
18 #define dazhi 2147483647
19 using namespace std;
20 
21 typedef long long ll;
22 
23 ll pow(ll a,ll b,ll p){ll sum=1;for(a%=p;b;a=a*a%p,b>>=1)if(b&1)sum=sum*a%p;return sum;}
24 ll phi(ll n){ll i,re=n;for(i=2;i*i<=n;i++)if(n%i==0){re=re/i*(i-1);while(n%i==0)n/=i;}if(n>1)re=re/n*(n-1);return re%M;}
25 void exgcd(ll a,ll b,ll &x,ll &y){if(!b){x=1;y=0;return;}exgcd(b,a%b,y,x);y-=x*(a/b);}
26 ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
27 
28 /****************************************/
29  int main()
30  {
31 
32      int t,n;
33      scanf("%d",&t);
34      while(t--)
35      {
36          scanf("%d",&n);
37          if(n==1)printf("Bob\n");
38          else printf("Alice\n");
39      }
40  }

 

H

  1 #include<iostream>
  2 #include<cstdio>
  3 #include<cmath>
  4 #include<cstring>
  5 #include<algorithm>
  6 #include<map>
  7 #include<queue>
  8 #include<stack>
  9 #include<vector>
 10 #include<bitset>
 11 #include<set>
 12 #define ll __int64
 13 #define mod 100000000
 14 #define N 5e6+10
 15 #define M 1e
 16 using namespace std;
 17 ll a[255]={ 
 18 1
 19 ,2
 20 ,2
 21 ,4
 22 ,3
 23 ,7
 24 ,5
 25 ,11
 26 ,8
 27 ,17
 28 ,12
 29 ,26
 30 ,18
 31 ,37
 32 ,27
 33 ,54
 34 ,38
 35 ,76
 36 ,54
 37 ,106
 38 ,76
 39 ,145
 40 ,104
 41 ,199
 42 ,142
 43 ,266
 44 , 192
 45 , 357,
 46  256,
 47  472,
 48  340,
 49  621,
 50  448,
 51  809,
 52  585,
 53  1053,
 54  760,
 55  1354,
 56  982,
 57  1740,
 58  1260,
 59  2218,
 60  1610,
 61  2818,
 62  2048,
 63  3559,
 64  2590,
 65  4485,
 66  3264,
 67 5616,
 68 4097,
 69  7018,
 70  5120,
 71  8728,
 72  6378,
 73  10826,
 74  7917,
 75  13373,
 76  9792,
 77 16484,
 78  12076,
 79  20236,
 80  14848,
 81  24793,
 82  18200,
 83  30275,
 84  22250,
 85  36886,
 86  27130,
 87  44810,
 88  32992,
 89  54329,
 90  40026,
 91  65683,
 92  48446,
 93  79265,
 94  58499,
 95  95419,
 96  70488,
 97  114650,
 98  84756,
 99  137447,
100  101698,
101  164496,
102  121792,
103  196445,
104  145578,
105  234221,
106  173682,
107  278720,
108  206848,
109  331143,
110  245920,
111  392722,
112  291874,
113  465061,
114  345856,
115  549781,
116  409174,
117  649019,
118 483330,
119  764959,
120  570078,
121  900373,
122  671418,
123  1058191,
124  789640,
125  1242061,
126  927406,
127  1455820,
128  1087744,
129  1704261,
130  1274118,
131  1992458,
132  1490528,
133  2326608,
134  1741521,
135  2713398,
136  2032290,
137  3160899,
138  2368800,
139  3677789,
140  2757826,
141  4274556,
142  3207086,
143  4962526,
144  3725410,
145  5755174,
146  4322816,
147  6667228,
148  5010688,
149  7716070,
150  5802008,
151  8920663,
152  6711480,
153  10303379,
154  7755776,
155  11888671,
156  8953856,
157  13705118,
158  10327156,
159  15784173,
160  11899934,
161  18162385,
162  13699699,
163  20879933,
164  15757502,
165  23983452,
166  18108418,
167  27524280,
168  20792120,
169  31561603,
170  23853318,
171  36160845,
172  27342421,
173  41397124,
174  31316314,
175  47353396,
176  35839008,
177  54124796,
178  40982540,
179  61816437,
180  46828032,
181  70548311,
182  53466624,
183  80453313,
184  61000704,
185  91682668,
186  69545358,
187  104403741,
188  79229676,
189  118806744,
190  90198446,
191  135102223,
192  102614114,
193  153528658,
194  116658616,
195  174350347,
196  132535702,
197  197865953,
198  150473568,
199  224406247,
200  170727424,
201  254344551,
202  193582642,
203  288094273,
204  219358315,
205 326120818,
206  248410816,
207  368939881,
208  281138048,
209  417130912,
210  317984256,
211  471335560,
212  359444904,
213  532274004,
214  406072422,
215  600743477,
216  458482688,
217  677637038,
218  517361670,
219  763943462,
220  583473184,
221  860768675,
222  657667584,
223  969336374,
224  740890786,
225  1091013811,
226  834194700,
227  1227313238,
228  938748852,
229  1379921672,
230  1055852590,
231  1550704877,
232  1186949056,
233  1741741564,
234  1333640710,
235  1955329266,
236  1497705768,
237  2194025352,
238  1681116852,
239  2460655086,
240  1886061684,
241  2758359212,
242  2114965120,
243  3090606588,
244  2370513986,
245  3461249193,
246  2655684608,
247  3874538905,
248  2973772212,
249  4335193118,
250  3328423936,
251  4848416380,
252  3723675326,
253  5419976831,
254  4163989458,
255  6056235989,
256  4654300706,
257  6764237552,
258  5200062976,
259  7551745299,
260  5807301632,
261  8427348786,
262  6482671322,
263  9400510845,
264  7233519619,
265  10481691022,
266  8067955712,
267  11682407480};
268 int  main()
269 {  int n;
270     while(scanf("%d",&n)!=EOF){
271         if(n==0)
272             break;
273         printf("%I64d\n",a[n-1]);
274     }
275     return  0;
276 }

 

I

 1 #include <cstdio>
 2 #include <cmath>
 3 #include <string>
 4 #include <cstring>
 5 #include <algorithm>
 6 #include <queue>
 7 #include <map>
 8 #include <set>
 9 #include <stack>
10 #include <sstream>
11 #include <vector>
12 #define PI acos(-1.0)
13 #define N 111111
14 #define M 1000000007
15 #define inf 1e9
16 #define eps 1e-8
17 #define dazhi 2147483647
18 using namespace std;
19 
20 typedef unsigned long long ll;
21 
22 ll pow(ll a,ll b,ll p){ll sum=1;for(a%=p;b;a=a*a%p,b>>=1)if(b&1)sum=sum*a%p;return sum;}
23 ll phi(ll n){ll i,re=n;for(i=2;i*i<=n;i++)if(n%i==0){re=re/i*(i-1);while(n%i==0)n/=i;}if(n>1)re=re/n*(n-1);return re%M;}
24 void exgcd(ll a,ll b,ll &x,ll &y){if(!b){x=1;y=0;return;}exgcd(b,a%b,y,x);y-=x*(a/b);}
25 ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
26 
27 /****************************************/
28 
29 ll b[N];
30 int main()
31 {
32     //ll x,y,t=0;
33     int n,x,y,t=0;
34     while(scanf("%d%d%d",&n,&x,&y)!=EOF){
35     t++;
36     if(n==0&&x==0&&y==0)break;
37     for(int i=1;i<=n;i++){
38         scanf("%lld",&b[i]);
39     }
40     for(int i=0;i<n;i++)
41         scanf("%lld",&b[n+n-i]);
42     if(x==2)y=2*n-y+1;
43     ll xiao=1e14,biao;
44     for(int i=y;i<=2*n;i++){
45         //xiao=min(xiao,b[i]);
46         if(b[i]<xiao)xiao=b[i],biao=i;
47     }
48     for(int i=1;i<y;i++){
49         if(b[i]<xiao)xiao=b[i],biao=i;
50     }
51     ll ans=0;
52     if(biao<y){
53         for(int i=1;i<=2*n;i++)
54             b[i]-=xiao+1,ans+=xiao+1;
55         for(int i=biao;i<y;i++)
56             b[i]++,ans--;
57     }
58     else{
59         for(int i=1;i<=2*n;i++)
60             b[i]-=xiao,ans+=xiao;
61         for(int i=y;i<biao;i++)
62             b[i]--,ans++;
63     }
64     b[biao]=ans;
65     printf("Case %d:\n",t);
66     if(biao<=n){
67         printf("INVALID\n");
68         continue;
69     }
70     for(int i=1;i<=n;i++){
71         printf("%lld ",b[i]);
72     }
73     cout<<endl;
74     for(int i=0;i<n;i++)
75     {
76          printf("%lld ",b[n+n-i]);
77     }
78     cout<<endl;
79     }
80 }

 

J

  1 #pragma comment(linker, "/STACK:102400000,102400000")
  2 #include <cstdio>
  3 #include <iostream>
  4 #include <cstdlib>
  5 #include <cstring>
  6 #include <algorithm>
  7 #include <cmath>
  8 #include <cctype>
  9 #include <map>
 10 #include <set>
 11 #include <queue>
 12 #include <bitset>
 13 #include <string>
 14 #include <complex>
 15 using namespace std;
 16 typedef pair<int,int> Pii;
 17 typedef long long LL;
 18 typedef unsigned long long ULL;
 19 typedef double DBL;
 20 typedef long double LDBL;
 21 #define MST(a,b) memset(a,b,sizeof(a))
 22 #define CLR(a) MST(a,0)
 23 #define SQR(a) ((a)*(a))
 24 #define PCUT puts("\n----------")
 25 
 26 const int maxn=500+10;
 27 const DBL eps=1e-8;
 28 int sgn(DBL x){return x>eps? 1: (x<-eps? -1: 0);}
 29 struct Vector
 30 {
 31     DBL x,y;
 32     Vector(DBL _x=0, DBL _y=0):x(_x),y(_y){}
 33     Vector operator + (const Vector &rhs) const {return Vector(x+rhs.x, y+rhs.y);}
 34     Vector operator - (const Vector &rhs) const {return Vector(x-rhs.x, y-rhs.y);}
 35     Vector operator * (const DBL &rhs) const {return Vector(x*rhs, y*rhs);}
 36     Vector operator / (const DBL &rhs) const {return Vector(x/rhs, y/rhs);}
 37     DBL operator * (const Vector &rhs) const {return x*rhs.x + y*rhs.y;}
 38     DBL operator ^ (const Vector &rhs) const {return x*rhs.y - rhs.x*y;}
 39     int read(){return scanf("%lf%lf", &x, &y);}
 40 };
 41 typedef Vector Point;
 42 
 43 struct Line
 44 {
 45     Point u,v;
 46     Line(){}
 47     Line(Point _u,Point _v):u(_u),v(_v){}
 48 };
 49 int N,M;
 50 Point A[maxn], B[maxn];
 51 DBL Area(int,Point*);
 52 DBL CPIA(Point*,Point*,int,int);
 53 DBL SPIA(Point*,Point*,int,int);
 54 
 55 int main()
 56 {
 57   int t;
 58   scanf("%d",&t);
 59   for(int p=1;p<=t;p++){
 60         scanf("%d%d", &N, &M);
 61         for(int i=0; i<N; i++) A[i].read();;
 62         for(int i=0; i<M; i++) B[i].read();
 63         printf("%.4f\n",SPIA(A,B,N,M));
 64   }
 65     return 0;
 66 }
 67 
 68 DBL Area(int siz, Point p[])
 69 {
 70     DBL res=0;
 71     for(int i=1; i<siz; i++) res += (p[i-1]^p[i]);
 72     res += (p[siz-1]^p[0]);
 73     return abs(res*0.5);
 74 }
 75 
 76 Point GetLineIntSec(Line l1, Line l2)
 77 {
 78     DBL a = (l1.v-l1.u)^(l2.u-l1.u), b = (l1.u-l1.v)^(l2.v-l1.v);
 79     if(sgn(a+b)==0) return Point(1e9,1e9);
 80     return Point((l2.u.x * b + l2.v.x * a) / (a + b), (l2.u.y * b + l2.v.y * a) / (a + b));
 81 }
 82 
 83 DBL CPIA(Point a[], Point b[], int na, int nb)
 84 {
 85     Point p[20], tmp[20]; // na,nb <=20
 86     int i, j, tn, sflag, eflag;
 87     a[na] = a[0], b[nb] = b[0];
 88     memcpy(p,b,sizeof(Point)*(nb + 1));
 89     for(i = 0; i < na && nb > 2; i++)
 90     {
 91         sflag = sgn((a[i+1]-a[i])^(p[0]-a[i]));
 92         for(j = tn = 0; j < nb; j++, sflag = eflag)
 93         {
 94             if(sflag>=0) tmp[tn++] = p[j];
 95             eflag = sgn( (a[i + 1]-a[i])^(p[j + 1]-a[i]));
 96             if((sflag ^ eflag) == -2)
 97                 tmp[tn++] = GetLineIntSec( Line(a[i], a[i + 1]) , Line(p[j], p[j + 1]));
 98         }
 99         memcpy(p, tmp, sizeof(Point) * tn);
100         nb = tn, p[nb] = p[0];
101     }
102     if(nb < 3) return 0.0;
103     return Area(nb, p);
104 }
105 
106 DBL SPIA(Point a[], Point b[], int na, int nb)
107 {
108     int i, j;
109     Point t1[4], t2[4];
110     double res = 0, num1, num2;
111     a[na] = t1[0] = a[0], b[nb] = t2[0] = b[0];
112     for(i = 2; i < na; i++)
113     {
114         t1[1] = a[i-1], t1[2] = a[i];
115         num1 = sgn( (t1[1]-t1[0])^(t1[2]-t1[0]));
116         if(num1 < 0) swap(t1[1], t1[2]);
117         for(j = 2; j < nb; j++)
118         {
119             t2[1] = b[j - 1], t2[2] = b[j];
120             num2 = sgn((t2[1]-t2[0])^(t2[2]-t2[0]));
121             if(num2 < 0) swap(t2[1], t2[2]);
122             res += CPIA(t1, t2, 3, 3) * num1 * num2;
123         }
124     }
125     return res;
126 }

 

以上是关于codeforces gym 100952 A B C D E F G H I J的主要内容,如果未能解决你的问题,请参考以下文章

Gym - 100952 B - New Job

Gym - 100952B

Gym 100952 A. Who is the winner?

Gym - 100952D

Gym - 100952G

Gym - 100952H