ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1063. Domino Puzzle

What wrong with this solution???
Posted by <P><P><P> 16 Apr 2003 14:15
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

short a[10000];
short sets[10000];
short p[10000];

int main()
{
  long i,n;
//  freopen("input.txt","rt",stdin);
//  freopen("output.txt","wt",stdout);

  while (scanf("%ld",&n)==1)
  {
  if (n==1) { printf("1\n"); continue; }
    long k,j,sum;
    sum=0;

    memset(a,0,sizeof(a));
    memset(sets,0,sizeof(sets));

    for (i=0; i<n; i++)
    {
      scanf("%ld",&k);
      for(j=2; j<=k; j++) a[j]--;
      sets[k]++;
      sum+=k;
    }
    for(j=2; j<=sum; j++) a[j]++;
    for(i=1; i<=sum; i++)
      for(j=2; j<=sets[i]; j++) a[j]--;

    memset(p,0,sizeof(p));
    unsigned long result=1;
    for(i=2; i<=sum; i++)
    if(!p[i])
    {
      j=i+i;
      while (j<=sum)
    { p[j]=1;
      k=j;
      while(k%i==0) {
        k/=i;
        a[i]+=a[j];
      }
      j+=i;
    }

      for(j=a[i]; j>=1; j--) result*=i;
    }
    printf("%lu\n",result);
  }

  exit(0);
  return 0;
}
?! how can I see 1063 problem?!!!
Posted by Locomotive 16 Apr 2003 16:51
http://acm.timus.ru/detail.asp?id=1063
Posted by Locomotive 16 Apr 2003 16:55
Noone has got AC on this problem since 14 Nov. 2001. It's just locked forever. Leonid Volkov, open it, please! Give us a chance to solve it (-)
Posted by Dmitry 'Diman_YES' Kovalioff 16 Apr 2003 22:15
>
How I must see the Description. There are no 1063 on set?
Posted by I am david. Tabo. 17 Apr 2003 17:45
> >
Re: What wrong with this solution???
Posted by Crazy Lemming 18 Apr 2003 14:30
You've made a terrible mistake. What does it mean "sum+=k"? IS NOT A
PASCAL STYLE! Use "sum=sum+k"!
Re: What wrong with this solution???
Posted by RoskaTa 6 Jun 2008 13:01
Crazy Lemming you are not very informed with C and C++!
It can be done in the way you say and in the way he made it!
In c++ and in C(as i suppose) sum+=k adds k to sum!
In pascal can be different but in C or C++ it isn't!

Edited by author 06.06.2008 13:04

Edited by author 06.06.2008 13:04