【#254_DIV2】-A B C
来源:互联网 发布:wpf高级编程 pdf 网盘 编辑:程序博客网 时间:2024/05/22 05:05
题目链接:http://codeforces.com/contest/445
解题报告:
俄国人今天不知道为什么九点钟就比赛了。只过了两道题,第三题完全没思路,有时间单独去刷第三题吧,看起来很难
A - DZY Loves Chessboard
太水了。。。
直接W、B错开填,顺便先抹上“ - ” 就完了
#include <iostream>#include <cstdio>#include <cstring>using namespace std;char grid[120][120],ans[120][120];int main(){ int n,m,i,j; cin>>n>>m; for(i=0;i<n;i++) { scanf("%s",grid[i]); } for(i=0;i<n;i++) { for(j=0;j<m;j++) { if(grid[i][j] == '-') {ans[i][j] = '-'; continue;} if(i%2 == 0) { if(j%2 ==0) ans[i][j] = 'W'; else ans[i][j] = 'B'; } else { if(j%2 ==0) ans[i][j] = 'B'; else ans[i][j] = 'W'; } } } for(i=0;i<n;i++) printf("%s\n",ans[i]); return 0;}
B -DZY Loves Chemistry
并查集直接搞,答案是 2 的 (n - m)次幂。
n 是药品种类数,m 是并查集并出来的集合的个数。
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>using namespace std;typedef unsigned long long ll;int arr[55];int find(int x){ return arr[x]==x?x:find(arr[x]);}void mer(int a,int b){ int fa,fb; fa=find(a); fb=find(b); if(fa!= fb) arr[fa]=fb;}ll p(int x,int y){ ll ans = 1; for(int i=1;i<=y;i++) ans *= x; return ans;}int main(){ int i,j,n,m,from,to; cin>>n>>m; for(i=1;i<=n;i++) arr[i] = i; while(m--) { scanf("%d%d",&from,&to); mer(from,to); } //for(i=1;i<=n;i++) cout<<arr[i]<<" "; cout<<endl; int t=0; for(i=1;i<=n;i++) { if(arr[i]==i) t++; } ll ans = p(2,n-t); cout<<ans<<endl; return 0;}
C - DZY Loves Physics
去看这道题的AC代码了,,,我擦,,,不该放弃这题的。。。
哈哈哈。。捶地笑,,,其实就是。
只剩两个点了!!!!!!!!!!!!!!!!!!!
不信你拿这个代码去试第三组数据,发现没有!
int main(){ freopen("input.txt","r",stdin); int n,m,c,from,to,i; cin>>n>>m; for(i=1;i<=n;i++) cin>>val[i]; while(m--) { cin>>from>>to>>c; cout<<(val[from]+val[to])/c<<endl; } return 0;}
完整的AC代码如下:
#include <iostream>#include <cstdio>#include <cstring>using namespace std;double val[550];int main(){ //freopen("input.txt","r",stdin); int n,m,c,from,to,i; cin>>n>>m; for(i=1;i<=n;i++) cin>>val[i]; double ans = 0; while(m--) { cin>>from>>to>>c; ans = max(ans,(val[from]+val[to])/c); } printf("%.12f\n",ans); return 0;}
0 0
- 【#254_DIV2】-A B C
- 【#248_DIV2】-A B C
- 【#249_DIV2】-A B C
- 【#247_DIV2】-A B C
- 【#253_DIV2】-A B D
- (a^b)%c和(a/b)%c
- SQL a>b?a:b, b>c?b:c
- Codeforces Rounds #254 div2:A,B,C
- A^B mod C
- A^B%C
- A^B mod C
- c = ( (++a) + (b++) );
- A+B+C
- a^b%c
- a+++b+c+++d++
- A^B mod C
- A=B+C
- A+B和C
- 东软实训(六)
- Codeforces445B_DZY Loves Chemistry(DFS/并查集)
- 东软实训(八)
- WebServices学习笔记(三)复杂类型数据的传递
- Clone Graph
- 【#254_DIV2】-A B C
- 一,入门基础—— 5,Xcode界面介绍 右侧介绍
- 【占位】IIS中各种队列
- http://photo.renren.com/photo/827157467/album-1034046772
- 2015年大数据市场规模超过170亿美元
- 变形金刚4:绝迹重生中文字幕抢先版BT种子下载
- 简单外中断实验(最近又要搞arm相关的东西,复习一下中断)
- poj 2513 欧拉回路+并查集判断是否联通+Trie树
- 浮点精度