题目链接:

232A - Cycles(点击打开)

题意:

要构成一个存在 \(k\) 个三元环的图,需要多少个点,输出顶点数 \(n\),并输出图。

题解:

题目中的任何图都可以用 \(90\)~ \(100\)个顶点构造完成。

Proof that \(100\) vertices are always enough for the given restrictions on \(n\).

- For some \(p\) after first \(p\) iterations we will have a complete graph of \(p\) vertices.

- Now we have exactly \(C(p, 3)\) triangles. Consider \(p\) such that \(C(p, 3)  ≤ k\) and \(C(p, 3)\) is maximal.

- For the given restrictions \(p ≤ 85\).

- From this moment, if we add \(u\) from some vertex, we increase the total number of 3-cycles on \(C(u, 2).\)

- So we have to present a small number that is less than \(C(85, 3)\) as sum of \(C(i, 2)\).

The first number we subtruct will differ \(C(85, 1)\) on some value not greater than \(C(85, 1) = 85\), because \(C(n, k) - C(n - 1, k) = C(n - 1, k - 1)\).

- The second number we subtruct will differ the number we have on some value not greater than \(C(14, 1) = 14.\)

- and so on.

- For every \(k\) it's enough to use not more that \(90\) vertices.

代码:

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int g[123][123];
int main()
{
int k;
cin>>k;//要求的三元环个数
for(int i=0;i<90;i++)//依次增加顶点
{
int sum = 0;//三元环个数
for(int j = 0; j < i && sum <= k;j++)
{
k-=sum;
sum++;
g[i][j] = g[j][i] = 1;
}
}
cout<<90<<endl;
for(int i=0;i<90;i++)
{
for(int j=0;j<90;j++)
{
int ans = g[i][j] ? 1:0;
cout<<ans;
}
cout<<endl;
}
return 0;
}

Codeforces 232A - Cycles (构造 + 思维)的更多相关文章

  1. codeforces 1041 e 构造

    Codeforces 1041 E 构造题. 给出一种操作,对于一棵树,去掉它的一条边.那么这颗树被分成两个部分,两个部分的分别的最大值就是这次操作的答案. 现在给出一棵树所有操作的结果,问能不能构造 ...

  2. Codeforces 755E:PolandBall and White-Red graph(构造+思维)

    http://codeforces.com/contest/755/problem/E 题意:给出n个点和一个距离d,让你在这个n个点的图里面构造一个子图,使得这个子图的直径和补图的直径的较小值为d, ...

  3. codeforces 454 E. Little Pony and Summer Sun Celebration(构造+思维)

    题目链接:http://codeforces.com/contest/454/problem/E 题意:给出n个点和m条边,要求每一个点要走指定的奇数次或者是偶数次. 构造出一种走法. 题解:可能一开 ...

  4. Codeforces 989 P循环节01构造 ABCD连通块构造 思维对云遮月参考系坐标轴转换

    A 直接判存不存在连续的三个包含A,B,C就行 /*Huyyt*/ #include<bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a ...

  5. Codeforces 1368E - Ski Accidents(构造+思维)

    Codeforces 题面传送门 & 洛谷题面传送门 神仙构造题(不过可能我构造太烂了?) 首先考虑这个奇奇怪怪的 \(\dfrac{4}{7}\),以及这个每个点出度最多为 \(2\) 的条 ...

  6. Codeforces 1090D - Similar Arrays - [思维题][构造题][2018-2019 Russia Open High School Programming Contest Problem D]

    题目链接:https://codeforces.com/contest/1090/problem/D Vasya had an array of n integers, each element of ...

  7. Codeforces Gym101503E:XOR-omania(构造+思维)

    题目链接 题意 给出m个数b,这些数是由n个数a两两异或组成的,问初始的那n个数分别是多少. 思路 存在多组解的情况...原来是个构造题. 考虑这样一种情况:b1 = a1 ^ a2,b2 = a2 ...

  8. codeforces 389 D. Fox and Minimal path(构造+思维)

    题目链接:https://vjudge.net/contest/175446#problem/J 题解:显然要用最多n个点构成的图要使的得到的最短路条数有1e9次个,显然要有几个数相乘容易想到2的几进 ...

  9. Educational Codeforces Round 102 (Rated for Div. 2) B. String LCM (构造,思维)

    题意:给你两个字符串\(a\)和\(b\),找出它们的\(lcm\),即构造一个新的字符串\(c\),使得\(c\)可以由\(x\)个\(a\)得到,并且可以由\(y\)个\(b\)得到,输出\(c\ ...

随机推荐

  1. Python基本循环实例Day 1

    输入正确的用户名和密码,显示登陆界面,超过三次输入错误则锁定,定义字符串记得加上单引号,数字可以int定义,while循环和if循环语句后加上:,break不加: print("------ ...

  2. Android学习总结(2)——App客户端与服务器交互中的token

    学习Token Token是什么? Token是服务端生成的一串字符串,以作客户端进行请求的一个令牌,当第一次登录后,服务器生成一个Token便将此Token返回给客户端,以后客户端只需带上这个Tok ...

  3. 洛谷 P3040 [USACO12JAN]贝尔分享Bale Share

    P3040 [USACO12JAN]贝尔分享Bale Share 题目描述 Farmer John has just received a new shipment of N (1 <= N & ...

  4. iOS 开发之IPad的设计与实现

    // // main.m // 6-ipad // #import <Foundation/Foundation.h> #import "Ipad.h" int mai ...

  5. javascript中易犯的错误有哪些

    javascript中易犯的错误有哪些 一.总结 一句话总结: 比如循环中函数的使用 函数中this的指向谁(函数中this的使用) 变量的作用域 1.this.timer = setTimeout( ...

  6. 网管软件 LANDesk的配置(视频配截图)

    网管软件 LANDesk Server Manager 8.5的配置截图         LANDesk桌面管理套件是应用于大中型企业环境下的计算机管理的最佳解决方案.它提供了从计算机资产管理.软件分 ...

  7. Codefroces 766D Mahmoud and a Dictionary

    D. Mahmoud and a Dictionary time limit per test 4 seconds memory limit per test 256 megabytes input ...

  8. 一台服务器安装运行多个Tomcat及注册服务

    项目需要,自己配置了一下,顺便分享出来. 1.下载对应版本Tomcat,这里下载Tomcat7.0.65.zip; 下载地址:http://archive.apache.org/dist/tomcat ...

  9. django框架初探

    django框架初探 1.web框架介绍 web框架本质是一个socket服务端.每一个端口只能被一个程序监听. web程序分为两个部分: 服务器程序:对socket服务器封装,解析http请求,发送 ...

  10. 【CS Round #39 (Div. 2 only) D】Seven-segment Display

    [Link]:https://csacademy.com/contest/round-39/task/seven-segment-display/ [Description] 0..9各自有一个数字, ...