Submission #19942

# Submission time Handle Problem Language Result Execution time Memory
19942 2016-02-25T07:40:59 Z onjo0127 악수 (kriii4_D) C++
0 / 100
0 ms 1084 KB
#include <stdio.h>
#include <algorithm>
#include <string.h>

#define MOD 1000000007

using namespace std;

int adj[41][41];
int net[41];
int n,mx=1;

void f(int key)
{
    int i,j;
    bool flag = true;
    for(i=1;i<=n;i++) {
        if(net[i]==0)flag=false;
    }
    if(flag)return;

    mx = max(key,mx);

    for(i=1;i<=n;i++) {
        for(j=i+1;j<=n;j++) {
            if(adj[i][j] == 0) {
                adj[i][j] = 1;
                net[i] = 1;
                net[j] = 1;
                f(key+1);
            }
        }
    }
}

int rev(int n)
{
    long long int a[35],m=1000000007,sum=1;
    int z,dt[15]={1,3,10,12,15,16,18,20,21,24,25,26,28,29,30};
    a[0]=1;a[1]=n;
    for(z=2;z!=35;z++)a[z]=(a[z-1]*a[z-1])%m;
    for(z=0;z!=15;z++)sum=(sum*a[dt[z]])%m;
    return sum;
}

int main()
{
    int i,j;
    unsigned long long a,b,cnt=0,sum=0;
    scanf("%d",&n);

    for(i=1;i<=n;i++) {
        for(j=i+1;j<=n;j++) {
            adj[i][j] = 1;
            net[i] = 1;
            net[j] = 1;
            f(2);
            ++cnt;
            sum += mx;
            mx=1;
            memset(net,0,sizeof(net));
        }
    }

    int g=__gcd(sum,cnt);
    sum/=g;
    cnt/=g;
    printf("%llu",(sum*rev(cnt))%MOD);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 1084 KB SIGFPE Floating point exception
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -