生活随笔
收集整理的這篇文章主要介紹了
2021 ICPC 江西省大学生程序设计竞赛(热身赛)【完结】
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
熱身賽,都是練手速的水題
目錄
- Abnormal unity
- Dripping Water Wears Through a Stone
- Follow me
- Strength team
Abnormal unity
https://ac.nowcoder.com/acm/contest/22659/A
#include<bits/stdc++.h>
using namespace std
;
const int N
=1e3+10;
int a
[N
][N
],n
;
int dx
[2][5]={{-1,1,0,0},{-1,-1,1,1}};
int dy
[2][5]={{0,0,-1,1},{-1,1,-1,1}};
int dfs(int x
,int y
,int op
)
{int res
=a
[x
][y
];for(int i
=0;i
<4;i
++){int tempx
=x
+dx
[op
][i
];int tempy
=y
+dy
[op
][i
];tempx
=(tempx
+n
)%n
;tempy
=(tempy
+n
)%n
;res
+=a
[tempx
][tempy
];}return res
;
}
int main(void)
{while(cin
>>n
,n
){for(int i
=0;i
<n
;i
++)for(int j
=0;j
<n
;j
++)cin
>>a
[i
][j
];int sum
=0; for(int i
=0;i
<n
;i
++){for(int j
=0;j
<n
;j
++){if(a
[i
][j
]&1) sum
+=dfs(i
,j
,0);else sum
+=dfs(i
,j
,1);}}cout
<<sum
<<endl
;}return 0;
}
Dripping Water Wears Through a Stone
https://ac.nowcoder.com/acm/contest/22659/B
#include<bits/stdc++.h>
using namespace std
;
int main(void)
{long long int m
,n
; cin
>>m
>>n
;cout
<<m
*n
;return 0;
}
Follow me
https://ac.nowcoder.com/acm/contest/22659/C
#include<bits/stdc++.h>
using namespace std
;
int main(void)
{int t
; cin
>>t
;string s
; getline(cin
,s
);while(t
--){getline(cin
,s
);cout
<<s
<<endl
;}return 0;
}
Strength team
https://ac.nowcoder.com/acm/contest/22659/D
#include<bits/stdc++.h>
using namespace std
;
bool cmp(int a
,int b
){return a
>b
;}
int main(void)
{int t
; cin
>>t
;while(t
--){vector
<int>A
,B
;int x
;for(int i
=0;i
<23;i
++) cin
>>x
,A
.push_back(x
);for(int i
=0;i
<23;i
++) cin
>>x
,B
.push_back(x
);sort(A
.begin(),A
.end(),cmp
);sort(B
.begin(),B
.end(),cmp
);int cnt1
=0,cnt2
=0;for(int i
=0;i
<23;i
++){if(A
[i
]>B
[i
]) cnt1
++;else cnt2
++;}if(cnt1
>cnt2
) puts("1");else puts("2");}return 0;
}
總結
以上是生活随笔為你收集整理的2021 ICPC 江西省大学生程序设计竞赛(热身赛)【完结】的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。