CSES - Datatähti 2019 alku - Results
Submission details
Task:Ruudukko
Sender:PekaaniP
Submission time:2018-10-14 18:58:00 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:47:5: error: expected ';' before 'std'
     std::cout << a;
     ^~~
input/code.cpp:33:12: warning: unused variable 'm' [-Wunused-variable]
     double m=0;
            ^

Code

#include <iostream>
#include <cmath>


long mod=1000000007;

double f(double n){
    int i=1;
    if(n==0){return 1;}
    double a=1;
    while(i <= n){
        a*=i;
        i++; }
    return a;
}
double nk(double n, double k){
    if(n==k){return 1;}
    return (f(n)/(f(k)*f(n-k)));
}
double nksum(double i, double n){
    int a=0;
    double c=i;
    while(i<n){
        a+=nk(i,c);
        i++;
    }
    return a;

}
int main() {
    double i=0;
    double n;
    double m=0;
    long a;
    double k;
    std::cin >> n;
    a=1;
    a=0;
    for(k=0; k<=n;k++){
        i=f(k)*pow(-1,n-k)*nk(n,k);
        i*=f(n);
        a+=i;
        a=a%mod;
    }

a=2*a
    std::cout << a;
}