11716 - Digital Fortress

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

Moderator: Board moderators

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11716 why CE ??

Post by brianfry713 » Fri Aug 10, 2012 10:09 pm

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".
Check input and AC output for thousands of problems on uDebug!

dante
New poster
Posts: 3
Joined: Fri Aug 10, 2012 4:30 pm

Re: 11716 why CE ??

Post by dante » Sat Aug 11, 2012 12:28 am

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" ?

dante
New poster
Posts: 3
Joined: Fri Aug 10, 2012 4:30 pm

Re: 11716 why CE ??

Post by dante » Sat Aug 11, 2012 11:03 pm

Oops ! I found out the reason...

emranbuet2002
New poster
Posts: 4
Joined: Sun Nov 11, 2012 2:37 am

Re: 11716 - Digital Fortress

Post by emranbuet2002 » Tue Nov 20, 2012 3:40 pm

Code: Select all

Removed after accepted
Last edited by emranbuet2002 on Wed Nov 21, 2012 5:11 am, edited 1 time in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11716 - Digital Fortress

Post by brianfry713 » Wed Nov 21, 2012 12:13 am

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)
Check input and AC output for thousands of problems on uDebug!

emranbuet2002
New poster
Posts: 4
Joined: Sun Nov 11, 2012 2:37 am

Re: 11716 - Digital Fortress

Post by emranbuet2002 » Wed Nov 21, 2012 5:11 am

Thanks!!!
I used another technique and it works

karyotype
New poster
Posts: 1
Joined: Fri Jan 04, 2013 11:33 pm

Re: 11716 - Digital Fortress

Post by karyotype » Fri Jan 04, 2013 11:37 pm

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;
}

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11716 - Digital Fortress

Post by brianfry713 » Mon Jan 07, 2013 3:39 am

try input

Code: Select all

2
WECGEWHYAAIORTNU
AAAA
Check input and AC output for thousands of problems on uDebug!

mazid
New poster
Posts: 6
Joined: Sun Dec 23, 2012 9:16 am

11716 - Digital Fortress WA??

Post by mazid » Sun Mar 31, 2013 8:27 am

Why getting WA??? :(
code removed after AC :D :lol:
Last edited by mazid on Sat Apr 06, 2013 7:33 pm, edited 1 time in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11716 - Digital Fortress WA??

Post by brianfry713 » Tue Apr 02, 2013 1:00 am

Doesn't match sample I/O. Don't use fflush(stdin);
Check input and AC output for thousands of problems on uDebug!

mazid
New poster
Posts: 6
Joined: Sun Dec 23, 2012 9:16 am

Re: 11716 - Digital Fortress WA??

Post by mazid » Sat Apr 06, 2013 7:32 pm

Accepted :D
Thanks brianfry713
It was a problem with fflush(stdin)

sakibrahman
New poster
Posts: 3
Joined: Wed May 22, 2013 10:33 pm

11716 - Digital Fortress

Post by sakibrahman » Wed May 22, 2013 10:44 pm

[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]

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: uva 11716 Getting wrong ans :(

Post by brianfry713 » Thu May 23, 2013 10:47 pm

Print INVALID not Invalid
Check input and AC output for thousands of problems on uDebug!

sakibrahman
New poster
Posts: 3
Joined: Wed May 22, 2013 10:33 pm

Re: uva 11716 Getting wrong ans :(

Post by sakibrahman » Sun May 26, 2013 10:07 pm

Thanks ... Got AC :)

alexiago
New poster
Posts: 14
Joined: Thu Jan 24, 2008 6:34 pm

Re: 11716 - Digital Fortress

Post by alexiago » Tue Oct 08, 2013 7:23 pm

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
Last edited by alexiago on Tue Oct 08, 2013 10:44 pm, edited 1 time in total.

Post Reply

Return to “Volume 117 (11700-11799)”