10079  Pizza Cutting
Moderator: Board moderators

 Experienced poster
 Posts: 192
 Joined: Sat Nov 30, 2002 5:14 am

 Learning poster
 Posts: 94
 Joined: Sat Oct 05, 2002 5:34 pm
 Location: CS  AIUB, Dhaka, Bangladesh.
 Contact:
Re
[c]long long a;
...
printf("%lld",...);[/c]
Is this both in the ANSI C ? plz, eXplain more.
...
printf("%lld",...);[/c]
Is this both in the ANSI C ? plz, eXplain more.
Sajid Online: www.sajidonline.com

 Guru
 Posts: 834
 Joined: Wed May 29, 2002 4:11 pm
 Location: Wroclaw, Poland
 Contact:
anupam  you have right....
In C/C++ I use something like this (for 64 bit integer, I use MS VC++ as main compiler at home):
and it's work great. you could create more definitions i.e. for unsigned or other data type. BTW the same efect give you if you use typedef in C/C++ instead of #define as I
Dominik
In C/C++ I use something like this (for 64 bit integer, I use MS VC++ as main compiler at home):
Code: Select all
#ifdef ONLINE_JUDGE /* parts for OJ system check */
#define LONG long long int
#define L_IN "%lld"
#else /* Windows VC++ part */
#define LONG __int64
#define L_IN "%I64d"
#endif
LONG a;
scanf(L_IN,&a);
printf(L_IN,a);
Dominik
If you really want to get Accepted, try to think about possible, and after that  about impossible ... and you'll get, what you want ....
Born from ashes  restarting counter of problems (800+ solved problems)
Born from ashes  restarting counter of problems (800+ solved problems)
10079
it gives WA help pleas
[pascal]program acm10079;
label 1;
var i,n:longint;
sum:comp;
begin
repeat
read(n);
if n<0 then goto 1;
sum:=n*n;
sum:=sum+n;
sum:=sum/2;
sum:=sum+1;
if n=0 then writeln(0) else writeln(round(sum));
until 1=2;
1:
end.
[/pascal]
[pascal]program acm10079;
label 1;
var i,n:longint;
sum:comp;
begin
repeat
read(n);
if n<0 then goto 1;
sum:=n*n;
sum:=sum+n;
sum:=sum/2;
sum:=sum+1;
if n=0 then writeln(0) else writeln(round(sum));
until 1=2;
1:
end.
[/pascal]
someone who like to solve informatic problems.
http://acm.uva.es/cgibin/OnlineJudge?AuthorInfo:29650
http://acm.uva.es/cgibin/OnlineJudge?AuthorInfo:29650
 Russell John
 New poster
 Posts: 40
 Joined: Mon Jul 21, 2003 9:21 am
 Location: Planet Earth
 Contact:
what you mean my algorithm is correct yes? then...?Or no...?
someone who like to solve informatic problems.
http://acm.uva.es/cgibin/OnlineJudge?AuthorInfo:29650
http://acm.uva.es/cgibin/OnlineJudge?AuthorInfo:29650
i think u can make more simple the algorithm
any way u have to hold the result in long long or long double. coz it can be bigger than long range.
long double %Lf
long long %lld
result= (n1)result+n
found the simple equation from that.
anyway if u can't then mail me. i will help u.
long double %Lf
long long %lld
result= (n1)result+n
found the simple equation from that.
anyway if u can't then mail me. i will help u.
this time WA
what next...............?
what next...............?
10079 WA...Why
First of all sorry for my bad english.
I think my formulas are right.
I I used this logic...
With every new line, the way that maximize the number of parts is that the new line pass over all the older lines, so with every new line you have n lines more, I mean, the line number five will add 5 more parts, for line 6 the pizza will have 6 more parts that when it has 5 lines, etc, etc...
From there I get the formulas but I get WA...
Here is my code:
[c]
CODE REMOVED
if somebody need help with this problem send me a PM
[/c]
If somebody knows why is wrong...please tell me.
I think my formulas are right.
I I used this logic...
With every new line, the way that maximize the number of parts is that the new line pass over all the older lines, so with every new line you have n lines more, I mean, the line number five will add 5 more parts, for line 6 the pizza will have 6 more parts that when it has 5 lines, etc, etc...
From there I get the formulas but I get WA...
Here is my code:
[c]
CODE REMOVED
if somebody need help with this problem send me a PM
[/c]
If somebody knows why is wrong...please tell me.
Last edited by midra on Thu May 20, 2004 1:18 am, edited 1 time in total.
HI
SIGSEGV is mainly due to invalid memory reference,
such as when you are trying to access invalid memory locs and/or
restricted memlocs.
As for your program I can only suggest, provided your formula is correct
to change
[c]
while(scanf("%ld",&temp)!=EOF)
[/c]
to something like
[c]
while(scanf("%ld",&temp) == 1)
[/c]
that takes care of a missing EOF and other weird endoffile stuff
hth
Suman
such as when you are trying to access invalid memory locs and/or
restricted memlocs.
As for your program I can only suggest, provided your formula is correct
to change
[c]
while(scanf("%ld",&temp)!=EOF)
[/c]
to something like
[c]
while(scanf("%ld",&temp) == 1)
[/c]
that takes care of a missing EOF and other weird endoffile stuff
hth
Suman
WA etc
two things I'd like to add:
1)no need for double(i.e floatpoint arithmetic)
2)check your formula
There's a very thin line between helping and spoiling a problem,
for further help PM me/search the net.
hth
Suman
1)no need for double(i.e floatpoint arithmetic)
2)check your formula
There's a very thin line between helping and spoiling a problem,
for further help PM me/search the net.
hth
Suman
WA etc
two things I'd like to add:
1)no need for double(i.e floatpoint arithmetic)
2)check your formula
There's a very thin line between helping and spoiling a problem,
for further help PM me/search the net.
hth
Suman
1)no need for double(i.e floatpoint arithmetic)
2)check your formula
There's a very thin line between helping and spoiling a problem,
for further help PM me/search the net.
hth
Suman
Unusual
On the problem cutting pizza. This works:
but this doesn't
you must change it to this:
does anyone know why this is?
Code: Select all
cout<<((n*(n+1))/2)+1<<endl;
Code: Select all
cout<<n*n*.5+n*.5+1<<endl;
Code: Select all
cout<<(long long)n*n*.5+n*.5+1<<endl;