10292 - The Gossiping System

All about problems in Volume 102. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
Sirso
New poster
Posts: 3
Joined: Tue Apr 19, 2005 1:50 am

10292 - The Gossiping System

Post by Sirso »

Someone please help, this one is driving me nuts...

I think it's correct to assume that n= (g*m)-n -> 2n=g*m , and that for
r=2 all the possible combinations have the form g=m+1.

for example (letters are persons,rows are groups):

Code: Select all

a a b d
b c c e
d e f f
Why doesn't this work? Thanks in advance!

Code: Select all

#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <unistd.h>
#include <fcntl.h>
#include <math.h>

#ifdef _MSC_VER
typedef _int64 Long;
typedef _int32 Int;
typedef unsigned _int64 ULong;
typedef unsigned _int32 UInt;
#elif __GNUC__
typedef long long Long;
typedef long Int;
typedef unsigned long long ULong;
typedef unsigned long UInt;
#elif __BCPLUSPLUS__
typedef __int64 Long;
typedef __int32 Int;
typedef unsigned __int64 ULong;
typedef unsigned __int32 UInt;
#else
typedef long Long;
typedef int Int;
typedef unsigned long ULong;
typedef unsigned int UInt;
#endif 
using namespace std;

main(void){
 
 unsigned int n,i;
 ULong x,d;
 ULong f,c;
 bool impar;
 
 #ifndef ONLINE_JUDGE 
   close (0); open ("myprog.in.txt", O_RDONLY); 
   close (1); open ("myprog.out.txt", O_WRONLY | O_CREAT | O_TRUNC, 0600); 
 #endif 
 
 scanf("%d\n",&n);
 if(n==0) exit(0);
 
 for(i=0;i<n;i++)
  {
    cin >> x;
    d=2*x;
    f=floor(sqrt(d)); 
    c=ceil(sqrt(d));  
    if ((d==(c*f) && (c!=f) && (d>2)))
        printf("Yes.\n",x);
    else
        printf("No.\n");
  }

}
Sirso
New poster
Posts: 3
Joined: Tue Apr 19, 2005 1:50 am

Post by Sirso »

Ok I've found out that the problem is probably the enormous size of the possible entry data (numbers up to 10^50).

Since BigInteger in C++ is pretty limited (the only version I've found doesn't support square roots), I've done it in Java since I've already implemented a function to do the Square Roots in BigInteger.

Now I'm really frustrated because the Java Corrector doesn't support BigIntegers...

Can someone give me a nice class for C++ for handling Big Integers??? One in which square root is supported please...

Thanks!
Post Reply

Return to “Volume 102 (10200-10299)”