Page 2 of 3

Re: 11716 why CE ??

Posted: Fri Aug 10, 2012 10:09 pm
by brianfry713
On my system using g++ I get these compile warnings:

Code: Select all

In function `int main()':
15: warning: assignment to `int' from `float'
15: warning: argument to `int' from `float'
22: warning: assignment to non-pointer type `char' from NULL
22: warning: argument to non-pointer type `char' from NULL
You can see your compile errors by clicking "My Submissions".

Re: 11716 why CE ??

Posted: Sat Aug 11, 2012 12:28 am
by dante
tnx.

here is the msg I get from uva.
code.cpp: In function 'int main()':
code.cpp:9:10: error: 'getchar' was not declared in this scope
code.cpp:13:12: error: 'gets' was not declared in this scope
code.cpp:22:16: warning: converting to non-pointer type 'char' from NULL
I can replace "getchar" with "cin.ignore" but what should I use instead of "gets" ?

Re: 11716 why CE ??

Posted: Sat Aug 11, 2012 11:03 pm
by dante
Oops ! I found out the reason...

Re: 11716 - Digital Fortress

Posted: Tue Nov 20, 2012 3:40 pm
by emranbuet2002

Code: Select all

Removed after accepted

Re: 11716 - Digital Fortress

Posted: Wed Nov 21, 2012 12:13 am
by brianfry713
It's probably a precision error. Don't try and compare two doubles using ==. Instead try something like:
#include <stdlib.h>
if(fabs(len-r*r)<0.5)

Re: 11716 - Digital Fortress

Posted: Wed Nov 21, 2012 5:11 am
by emranbuet2002
Thanks!!!
I used another technique and it works

Re: 11716 - Digital Fortress

Posted: Fri Jan 04, 2013 11:37 pm
by karyotype
WHY RTE???

#include<string.h>
#include<stdio.h>
#include<math.h>
int main()
{
char str[10000],dummy;
int i,j,l,p,t;
scanf("%d%c",&t,&dummy);
while(t--)
{

gets(str);

l = strlen(str);
int p = sqrt(l);
if(p*p==l)
{
for(i=0; i<p; i++)
{
for(j=i; str[j]!='\0'; j+=p)
printf("%c",str[j]);
}

printf("\n");
}
else
printf("INVALID\n");


}
return 0;
}

Re: 11716 - Digital Fortress

Posted: Mon Jan 07, 2013 3:39 am
by brianfry713
try input

Code: Select all

2
WECGEWHYAAIORTNU
AAAA

11716 - Digital Fortress WA??

Posted: Sun Mar 31, 2013 8:27 am
by mazid
Why getting WA??? :(
code removed after AC :D :lol:

Re: 11716 - Digital Fortress WA??

Posted: Tue Apr 02, 2013 1:00 am
by brianfry713
Doesn't match sample I/O. Don't use fflush(stdin);

Re: 11716 - Digital Fortress WA??

Posted: Sat Apr 06, 2013 7:32 pm
by mazid
Accepted :D
Thanks brianfry713
It was a problem with fflush(stdin)

11716 - Digital Fortress

Posted: Wed May 22, 2013 10:44 pm
by sakibrahman
[What is the problem??]
[#include <stdio.h>
#include <string.h>
#include <math.h>
int main()
{
char a[10000],b[10000];
int i,j,t;
scanf("%d",&t);
getchar();
for(i=0;i<t;i++)
{
gets(a);
int x = sqrt(strlen(a));
if(x*x!=strlen(a)) {printf("Invalid\n");}
else
{
int k = 0,p=0,r=0;
while(p!=strlen(a))
{
printf("%c",a[k]);
if((k+x)>=strlen(a)) {r++;k=0;k+=r;}
else
k+=x;
p++;
}
printf("\n");
}



}




}
][/code]

Re: uva 11716 Getting wrong ans :(

Posted: Thu May 23, 2013 10:47 pm
by brianfry713
Print INVALID not Invalid

Re: uva 11716 Getting wrong ans :(

Posted: Sun May 26, 2013 10:07 pm
by sakibrahman
Thanks ... Got AC :)

Re: 11716 - Digital Fortress

Posted: Tue Oct 08, 2013 7:23 pm
by alexiago
I passed the algorithm below in C++ but I'm getting TLE in Java, everyone knows that Java can be slower but I was wondering what's causing this. Maybe reading lines as strings and using charAt? Maybe the Math.sqrt function? Any ideas?

Code: Select all

Removed after AC, used BufferedReader/BufferedWriter