Translate

Showing posts with label math. Show all posts
Showing posts with label math. Show all posts

Wednesday, 4 February 2015

111…1 Squared(GUANGGUN) spoj problem solution

HII guys this is good problem
here u have to find out pattern by printing squares.....
here squares of length 1 to 50 are
then after this u can find out pattern


1
121
12321
1234321
123454321
12345654321
1234567654321
123456787654321
12345678987654321
1234567900987654321
123456790120987654321
12345679012320987654321
1234567901234320987654321
123456790123454320987654321
12345679012345654320987654321
1234567901234567654320987654321
123456790123456787654320987654321
12345679012345678987654320987654321
1234567901234567900987654320987654321
123456790123456790120987654320987654321
12345679012345679012320987654320987654321
1234567901234567901234320987654320987654321
123456790123456790123454320987654320987654321
12345679012345679012345654320987654320987654321
1234567901234567901234567654320987654320987654321
123456790123456790123456787654320987654320987654321
12345679012345679012345678987654320987654320987654321
1234567901234567901234567900987654320987654320987654321
123456790123456790123456790120987654320987654320987654321
12345679012345679012345679012320987654320987654320987654321
1234567901234567901234567901234320987654320987654320987654321
123456790123456790123456790123454320987654320987654320987654321
12345679012345679012345679012345654320987654320987654320987654321
1234567901234567901234567901234567654320987654320987654320987654321
123456790123456790123456790123456787654320987654320987654320987654321
12345679012345679012345679012345678987654320987654320987654320987654321
1234567901234567901234567901234567900987654320987654320987654320987654321
123456790123456790123456790123456790120987654320987654320987654320987654321
12345679012345679012345679012345679012320987654320987654320987654320987654321
1234567901234567901234567901234567901234320987654320987654320987654320987654321
123456790123456790123456790123456790123454320987654320987654320987654320987654321
12345679012345679012345679012345679012345654320987654320987654320987654320987654321
1234567901234567901234567901234567901234567654320987654320987654320987654320987654321
123456790123456790123456790123456790123456787654320987654320987654320987654320987654321
12345679012345679012345679012345679012345678987654320987654320987654320987654320987654321
1234567901234567901234567901234567901234567900987654320987654320987654320987654320987654321
123456790123456790123456790123456790123456790120987654320987654320987654320987654320987654321
12345679012345679012345679012345679012345679012320987654320987654320987654320987654320987654321
1234567901234567901234567901234567901234567901234320987654320987654320987654320987654320987654321
123456790123456790123456790123456790123456790123454320987654320987654320987654320987654320987654321


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#include<stdio.h>
#include<stdlib.h>
int main()
{
 long long int n,t,s,k;
 while(scanf("%lld",&n)!=EOF)
 {
  if(n<10)
  {
   printf("%lld\n",n*n);
   continue;
  }
  t=((n-10)/9)+1;
  k=10+((t-1)*9);
  s=((81*t)+1)+((n-k)*(n-k+2));
  printf("%lld\n",s);
 }
 return 0;
}

COEF(Coeficientes) spoj problem solution

HII guys this is one of the easy problem
the only thing that is u should know what
is multinomial theorem and how how to calculate
multinomial coefficient....
FORMULA::
 (n_1,n_2,...,n_k)!=((n_1+n_2+...+n_k)!)/(n_1!n_2!...n_k!)

here is my ac c++ solution is::



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
int main()
{
 LL fact[]={1,1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600};
 int n,k,x,i;
 while(scanf("%d",&n)!=EOF)
 {
  scanf("%d",&k);
  LL ans=fact[n];
  for(i=1;i<=k;i++)
  {
   scanf("%d",&x);
   ans/=fact[x];
  }
  printf("%lld\n",ans);
 }
}

Working With Java Collections