牛客多校第7场E题

链接:https://www.nowcoder.com/acm/contest/145/E
来源:牛客网
 

题目描述

You love doing graph theory problems. You've recently stumbled upon a classical problem : Count the number of 4-cliques in an undirected graph.

Given an undirected simple graph G, a 4-clique of G is a set of 4 nodes such that all pairs of nodes in this set are directly connected by an edge.

This task would be too easy for you, wouldn't it? Thus, your task here is to find an undirected simple graph G with exactly k 4-cliques. Can you solve this task?

 

输入描述:

The first line of input contains a single integer k (1 ≤ k ≤ 106).

输出描述:

On the first line, output two space-separated integers, n, m (1 ≤ n ≤ 75, 1 ≤ m ≤ n * (n - 1) / 2). On the next m lines, output two space-separated integers denoting an edge of the graph u, v (1 ≤ u, v ≤ n), where u and v are the endpoints of the edge.

Your graph must not contain any self-loops or multiple edges between the same pair of nodes. Any graph that has exactly k 4-cliques and satisfies the constraints will be accepted. It can be proven that a solution always exist under the given constraints.

示例1

输入

复制

1

输出

复制

4 6
1 2
1 3
1 4
2 3
2 4
4 3

说明

In the sample, the whole graph is a 4-clique.

思路: 对于一个n个点的完全图,我们可以构造出Cn,4  个,而对于Cn+1,4,之间的那个个数,我们只能通过另外的点进行加边来操作,对于每一个点加x条边,就会形成Cx,3 个,那么70 的完全图是910000多 71是960000多好像,这样的话,其实可以拿出来5个点,如果用71的完全图去构造,,好像不可以。 坑点是点必须是连续的,,wa了一晚上。。

代码:

#include

using namespace std;
typedef pair pii;
typedef long long ll;

const int N=78;

int c4[N];
int c3[N];
int vis[28400];
int k;
int mp[75*75*75];

int C4(int n)
{
    return n*(n-1)*(n-2)*(n-3)/24;
}

int C3(int n)
{
    return n*(n-1)*(n-2)/6;
}

void init()
{
    for(int i=1;i<=76;i++){
        c4[i]=C4(i);
        c3[i]=C3(i);
        mp[c3[i]]=i;
    }
    mp[0]=0;
    c3[0]=c3[1]=c3[2]=0;
    c4[0]=c4[1]=c4[2]=c4[3]=0;
}

vector  ans;

int main()
{
    memset(mp,-1,sizeof(mp));
    init();
    //cout<=0&&mp[re]!=-1&&mp[re]<=in){
                        e=mp[re];
                        //cout<<"e "<<" res "<

 

你可能感兴趣的:(数学)