【CodeForces】233C - Cycles(贪心)
来源:互联网 发布:网络音乐在线听歌曲 编辑:程序博客网 时间:2024/06/16 16:03
题目链接:点击打开链接
每添加一条线,贡献多少个环要算好,然后就不难了。
代码如下:
#include <cstdio>#include <stack>#include <queue>#include <cmath>#include <vector>#include <cstring>#include <algorithm>using namespace std;#define CLR(a,b) memset(a,b,sizeof(a))#define INF 0x3f3f3f3f#define LL long longint mapp[111][111];int main(){int n;scanf ("%d",&n);int l = 2;int ant = 0;mapp[1][2] = mapp[2][1] = 1;for (int i = 3 ; i <= 100 ; i++){l = max(l,i);mapp[i][1] = mapp[1][i] = 1;for (int j = 2 ; j < i ; j++){mapp[i][j] = mapp[j][i] = 1;ant += j-1;if (ant == n)break;else if (ant > n){ant -= j-1;mapp[i][j] = mapp[j][i] = 0;break;}}if (ant == n)break;}printf ("%d\n",l);for (int i = 1 ; i <= l ; i++){for (int j = 1 ; j < l ; j++)printf ("%d",mapp[i][j]);printf ("%d\n",mapp[i][l]);}return 0;}
0 0
- 【CodeForces】233C - Cycles(贪心)
- codeforces 233c Cycles【贪心】
- CodeForces 233C Cycles(思维)
- CodeForces 233 C.Cycles(构造)
- 【codeforces 233C Cycles】+ 思维
- Codeforces-----233C---Cycles模拟
- Codeforces 233C Cycles(图的三元环)
- codeforces 232A Cycles (构建图,贪心+模拟)
- codeforces 232A Cycles 图论 贪心 思维
- Codeforces Round #144 (Div. 2) C. Cycles
- CodeForces 508C (贪心)
- Codeforces 805C (贪心)
- CodeForces 478C (贪心)
- CF232A-cycles 构造,贪心
- Codeforces 394C Dominoes(贪心)
- Codeforces 401C Team(贪心+暴力)
- CodeForces 416C Booking System(贪心)
- CodeForces 460C--- Present(二分+贪心)
- gdb调试core文件与程序
- nodejs中间件
- Ubuntu常见错误问题解决
- 大端小端判断
- 进程和线程、协程的区别
- 【CodeForces】233C - Cycles(贪心)
- IOS用CGContextRef画各种图形(文字、圆、直线、弧线、矩形、扇形、椭圆、三角形、圆角矩形、贝塞尔曲线、图片)
- 说说JSON和JSONP,也许你会豁然开朗,含jQuery用例
- entity framework 事务
- perfect素数3274
- linux—套接字
- 【Python】初识Python的学习笔记
- 微信小应用第一天(简介)
- 【Data Structures】 6. Queue—Another limited data structure and FIFO