Saratov State University :: Online Contester


::Go
- home
- news
- register
- update personal info
- problemset archive
- submit
- status online
- standing
- contests
- virtual contests
- forum
- statistic
- FAQ
- links
- projects

::Poll
Are you registered on Codeforces?
Yes
No
What is it???

[results]

::webboard

I have WA on test 3 please help
Author: paunmatei7
ID: 059022
Problem: 269
Contest: 0
Date: 2013-08-01 18:40:12

#include<stdio.h>
#include<string.h>
#include<algorithm>

#define NMAX 257

using namespace std;

int a[NMAX];
int n, k;
short int D[NMAX][NMAX][NMAX], aux[NMAX];

void adun(short int aa[] , short int bb[]){
int i,t=0;
aa[0] = max(aa[0], bb[0]);
for (i=1;i<=aa[0];i++){
aa[i]+=bb[i]+t;
t=aa[i]/10;
aa[i]%=10;
}
if (t)
aa[++aa[0]]=t;
}

void prod(short int h[], int x){
int t=0;
for(int i = 1; i <= h[0]; ++ i){
h[i] *= x;
h[i] += t;
t = h[i] / 10;
h[i] %= 10;
}
while (t)
h[++ h[0]] = t % 10, t /= 10;
}

int main(){
scanf("%d %d", &n, &k);
for(int i = 1; i <= n; ++ i)
scanf("%d", &a[i]);
sort(a + 1, a + n + 1);
/**D[0][0] = 1;
for(int i = 0; i < n; ++ i)
for(int j = 0; j <= k; ++ j)
D[i + 1][j] += D[i][j], D[i + 1][j + 1] += D[i][j] * (a[i + 1] - j);
printf("%lld", D[n][k]);*/
D[0][0][0] = D[0][0][1] = 1;
for(int i = 0; i < n; ++ i)
for(int j = 0; j < k; ++ j){
adun(D[i + 1][j], D[i][j]);
memset(aux, 0, sizeof(aux));
memcpy(aux, D[i][j], sizeof(aux));
prod(aux, a[i + 1] - j);
adun(D[i + 1][j + 1], aux);
}
for(int i = D[n][k][0]; i >= 1; -- i)
printf("%d", D[n][k][i]);
printf("n");
return 0;
}


see sub-tree reply to that message


::Login
Forgot password?

::News
22.10.12 - The problems from the Southern Subregional Programming Contest 2012 added to the problemset archive (542 - 553).
22.10.12 - After the start of the contest the statements in PDF will be available by the link.
23.10.11 - The problems from the Southern Subregional Programming Contest 2011 added to the problemset archive (530 - 541).

::Counter

Server time: 2017-09-22 20:51:28Online Contester Team © 2002 - 2016. All rights reserved.