Page 2 of 3
Posted: Fri Feb 14, 2003 6:36 am
by Red Scorpion
Just declare the variable as:
long long a;
sample:
int main() {
..long long a;
..a = 22345672948472475823;
.. printf ("%lld\n", a);
}
*for scanf and printf use the flag "%lld" *
Just that,
Good Luck!

Re
Posted: Fri Feb 21, 2003 8:15 pm
by Sajid
[c]long long a;
...
printf("%lld",...);[/c]
Is this both in the ANSI C ? plz, eXplain more.
Posted: Mon Feb 24, 2003 8:32 pm
by Jalal
Its better to solve by a simple math law of High
school which u used to make
1+2+3+4+.....+n
just add 1 more to it.
Yes sajid that lld works with Turbo C
but not with borland C++
Posted: Thu Feb 27, 2003 11:28 pm
by anupam
i think lld works in only linux and unix platform..
turbo c uses it but don't store actual amount of data that gcc store in linux..
Posted: Fri Feb 28, 2003 9:22 am
by Dominik Michniewski
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):
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);
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
10079
Posted: Mon Dec 01, 2003 9:29 pm
by Eduard
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]
Posted: Tue Dec 02, 2003 11:06 am
by Russell John
Your algorithm is inefficient.
Posted: Tue Dec 02, 2003 12:56 pm
by Eduard
what you mean my algorithm is correct yes? then...?Or no...?
i think u can make more simple the algorithm
Posted: Wed Dec 17, 2003 6:22 pm
by osan
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= (n-1)result+n
found the simple equation from that.
anyway if u can't then mail me. i will help u.
10079 WA...Why
Posted: Fri May 14, 2004 3:50 am
by midra
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.
HI
Posted: Fri May 14, 2004 4:54 am
by sumankar
SIGSEGV is mainly due to invalid memory reference,
such as when you are trying to access invalid memory locs and/or
restricted mem-locs.
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 end-of-file stuff
hth
Suman
Posted: Sat May 15, 2004 1:28 am
by midra
Thank you 'Again' sumankar.

I have changed but I still got WA.... It never says SIGSEGV or an error like that, I always get WA...
I think maybe the type double is the problem, but I don't know...
WA etc
Posted: Sat May 15, 2004 7:56 pm
by sumankar
two things I'd like to add:
1)no need for double(i.e float-point 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
Posted: Sat May 15, 2004 7:59 pm
by sumankar
two things I'd like to add:
1)no need for double(i.e float-point 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
Posted: Sat Aug 12, 2006 3:23 am
by mhayter1
On the problem cutting pizza. This works:
but this doesn't
you must change it to this:
Code: Select all
cout<<(long long)n*n*.5+n*.5+1<<endl;
does anyone know why this is?