Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #define MOD 555557
- using namespace std;
- ifstream f("necuatie.in");
- ofstream g("necuatie.out");
- long long n,nr,i,j,c[2001][2001];
- int main()
- {
- f>>n;
- /// Calculez combinarile de i luate cate j, cu i<=n
- c[1][0]=1;
- c[1][1]=1;
- for(i=2;i<=n;++i)
- {
- c[i][0]=1;
- c[i][i]=1;
- for(j=1;j<i;++j)
- c[i][j]=(c[i-1][j-1]+c[i-1][j])%MOD;
- }
- /// Aflu numarul solutiilor
- nr=1 ;
- if(n%2==0)
- for(i=0;i<=n-2;i+=2)
- nr=(nr+c[n][i]*c[n-i][(n-i)/2])%MOD;
- else
- for(i=1;i<=n-2;i+=2)
- nr=(nr+c[n][i]*c[n-i][(n-i)/2])%MOD;
- g<<nr;
- return 0;
- }
Add Comment
Please, Sign In to add comment