Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9274941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:28:18+00:00 2026-06-18T16:28:18+00:00

I have this code: #include<iostream> #include<algorithm> #define mod 1000000007 using namespace std; unsigned long

  • 0

I have this code:

#include<iostream>
#include<algorithm>

#define mod 1000000007

using namespace std;
unsigned long long int pow(int);
unsigned long long int binomialCoeff(int ,int );
int i,j;
int T[1000][1000];

int main()
{
    unsigned long long int t,k,n,ans;
    cin>>t;
    while(t--)
    {
        ans=0;
        cin>>n;
        int a[n];
        for(i=0;i<n;i++)
        cin>>a[i];

        if(n%2==0)
            ans=(pow(n-1)-((binomialCoeff(n,n/2))/2))%mod;
        else
            ans=pow(n-1)%mod;

        printf("%lld\n",ans);
    }

    system("pause");
}

unsigned long long int binomialCoeff(int na,int rb)
{

    for(i=0;i<na-rb+1;i++)
        **T[i,0]=1;**

    for(i=0;i<rb+1;i++)
        **T[i,i]=1;**

    for(j=1;j<rb+1;j++)
    {           
        for(i=j+1;i<na-rb+j+1;i++)
            **T[i,j]=T[i-1,j-1]+T[i-1,j];**
    }
    return (T[na,rb]);
}


unsigned long long int pow(int n)
{
    int k;

    if(n==0)
        return 1;
    else if(n%2==0)
        {k=pow(n/2);return ((k%mod)*(k%mod))%mod;}
    else
        {k=pow(n/2);return ((((k%mod)*(k%mod))%mod)*2)%mod;}
}

I have this algorithm:

2^(n-1) - ((1+(-1)^n)/4)*binomial(n, n/2)

…for this question.

But in my compiler I am getting compilation errors:

In function `long long unsigned int binomialCoeff(int, int)': 
   incompatible types in assignment of `int' to `int[1000]' 
   invalid operands of types `int[1000]' and `int[1000]' to binary `operator+' 
   invalid conversion from `int*' to `long long unsigned int' 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T16:28:20+00:00Added an answer on June 18, 2026 at 4:28 pm

    Your array access syntax is wrong. Try:

    T[i][0] = 1;
    

    This is true in all of your usage of the multidimensional arrays. For example, later, this:

    // Bad code from original post
    T[i,j]=T[i-1,j-1]+T[i-1,j]
    

    Should be written as:

    T[i][j]=T[i-1][j-1]+T[i-1][j];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have next code: #include <iostream> #include <algorithm> #include <map> #include <iterator> //namespace std
I have this code: #include <iostream> #include <functional> struct A { int operator()(int i)
I have a code like this below in /root_project/main.cpp : #include theoraplayer/TheoraVideoClip.h unsigned int
Code: #include <iostream> #include <string> #include <sstream> #include <algorithm> using std::cerr; using std::cout; using
I have this code: #include <stdio.h> #include <openssl/sha.h> #include <openssl/ssl.h> int main(){ printf(OpenSSL version:
I have this code which does the trick: #include <stdio.h> int main() { int
I have such code which works well: #include <algorithm> #include <iostream> char x[11]= ABCDEFGHIJ;
I have this code which will include template.php file from inside each of these
I have this code <html> <include jquery> <script> function crea() { var html =
If I have a global static variable x like in this code #include <stdio.h>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.