2021 ICPC网络赛第二场9月25日
本人小菜鸡,A了M题,数学大佬A了G,还有一个A了J题,对于此次战果还是有点满意的(大佬别喷呜呜呜~)。
G题limit
题意:给一个公式求洛必达,t<=5,最多求五次,并且第i次能洛的前提是前几次都是0/0式或无穷式,暴力算五次就好了,开long long。
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99#include<bits/stdc++.h> using namespace std; typedef long long ll; const int MAX=1e5+5; ll a[MAX],b[MAX]; ll gcd(ll x,ll y){ if(x%y==0) return y; else return gcd(x%y,y); } int main() { ll luo[6]={0,1,1,2,6,24};//洛i次的常数,不带正负号 ll N,T,t1=0,t2=0,t3=0,t4=0,t5=0; scanf("%lld %lld",&N,&T); for(int i=1;i<=N;i++) scanf("%lld %lld",&a[i],&b[i]); for(int i=1;i<=N;i++) t1+=luo[1]*a[i]*pow(b[i],1); for(int i=1;i<=N;i++) t2+=luo[2]*a[i]*pow(b[i],2); for(int i=1;i<=N;i++) t3+=luo[3]*a[i]*pow(b[i],3); for(int i=1;i<=N;i++) t4+=luo[4]*a[i]*pow(b[i],4); for(int i=1;i<=N;i++) t5+=luo[5]*a[i]*pow(b[i],5); t2=-t2;//偶数求导的常数为负数 t4=-t4; if(T==0) { printf("0"); } else if(T==1) { printf("%lld",t1); } else if(T==2) { if(t1==0) { if(t2%2==0)//常数gcd printf("%lld",t2/2); else printf("%lld/2",t2); } else printf("infinity"); } else if(T==3) { if(t1==0&&t2==0) { if(t3%6==0) printf("%lld",t3/6); else { int fm=gcd(t3,6); printf("%lld/%lld",t3/fm,6/fm); } } else printf("infinity"); } else if(T==4) { if(t1==0&&t2==0&&t3==0) { if(t4%24==0) printf("%lld",t4/24); else { int fm=gcd(t4,24); printf("%lld/%lld",t4/fm,24/fm); } } else printf("infinity"); } else if(T==5) { if(t1==0&&t2==0&&t3==0&&t4==0) { if(t5%120==0) printf("%lld",t5/120); else { int fm=gcd(t5,120); printf("%lld/%lld",t5/fm,120/fm); } } else printf("infinity"); } return 0; }
J题
题意:好像是求水留到高度为0的地方,求各个高度为0地点的流水量。
吐槽:能不用memset绝对别用,因为这个TL了好几发呜呜呜~
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99#include<stdio.h> #include<cstring> #include<algorithm> #include<queue> using namespace std; const int MAX=505; int N; int dx[4]={0,0,-1,1}; int dy[4]={-1,1,0,0}; bool vis[MAX][MAX]; int H[MAX][MAX]; double wate[MAX][MAX]; struct node{ int x,y,h; }t[MAX*MAX]; queue<node>p; queue<node>q; bool pd(int x,int y) { if(x<1||x>N||y<1||y>N) return false; return true; } void bfs(int X,int Y) { node pp; pp.x=X,pp.y=Y; q.push(pp); // memset(vis,false,sizeof(vis)); while(!q.empty()) { node qq=q.front(); q.pop(); int x=qq.x,y=qq.y; vis[x][y]=true; double cnt=0; for(int i=0;i<4;i++) { int xx=x+dx[i],yy=y+dy[i]; if(!pd(xx,yy)) continue; if(H[xx][yy]<H[x][y]) cnt++; } if(cnt==0) continue; for(int i=0;i<4;i++) { int xx=x+dx[i],yy=y+dy[i]; if(!pd(xx,yy)) continue; double temp=wate[x][y]/cnt; if(H[xx][yy]<H[x][y]) { node qqq; qqq.x=xx,qqq.y=yy; if(!vis[xx][yy]&&H[xx][yy]!=0) q.push(qqq); vis[xx][yy]=true; wate[xx][yy]+=temp; } } wate[x][y]=0; } } bool cmp(node x,node y) { return x.h>y.h; } int main() { int M,Max=0,cnt=0; scanf("%d %d",&N,&M); for(int i=1;i<=N;i++) { for(int j=1;j<=N;j++) { wate[i][j]=M; scanf("%d",&H[i][j]); t[cnt].x=i,t[cnt].y=j,t[cnt].h=H[i][j]; cnt++; } } sort(t,t+cnt,cmp); for(int i=0;i<cnt;i++) { int xx=t[i].x,yy=t[i].y; if(wate[xx][yy]!=0&&H[xx][yy]!=0) bfs(xx,yy); } for(int i=1;i<=N;i++) { for(int j=1;j<=N;j++) if(H[i][j]==0) printf("%.6f ",wate[i][j]); else printf("0 "); printf("n"); } return 0; }
M题
题意:给出数组n,a和b,n代表二进制ai和bi是正(ai * 1)或负(ai * -1),求数组c:ai+bi=ci,就是构造一个二进制数,如果满二且前位相同往前进1,否则往前借一位。
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44#include<bits/stdc++.h> using namespace std; int sqn[70],a[70],b[70],c[70],n; int main() { scanf("%d",&n); for(int i=1;i<=n;i++)scanf("%d",&sqn[i]); for(int i=1;i<=n;i++)scanf("%d",&a[i]); for(int i=1;i<=n;i++)scanf("%d",&b[i]); for(int i=1;i<=n;i++)c[i]=a[i]+b[i]; for(int i=1;i<=n;i++) { if(c[i]>=2) { c[i]-=2; int j=i+1; if(sqn[j]==sqn[i])c[j]++; else { if(c[j]>0)c[j]--; else { while(sqn[i]!=sqn[j]) { if(c[j]==0)c[j]=1,j++; else { c[j]--; break; } } if(sqn[i]==sqn[j])c[j]++; } } } } for(int i=1;i<=n;i++) { if(i!=n)printf("%d ",c[i]); else printf("%d",c[i]); } return 0; }
最后
以上就是高贵毛豆最近收集整理的关于2021 ICPC网络赛第二场9月25日2021 ICPC网络赛第二场9月25日的全部内容,更多相关2021内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复