codes not working when I use %lld or %ld in codechef...

Guys I am facing an TLE error while using %ld(long integer) and %lld(long long integer) in codechef . . . Instead %ld, %lld when I use %d 50% tet cases are correct. But in Code:Blocks or any other IDE
%lld is required to get the right answer.

2 Likes

I’ve used %lld filter and it used to work. So I guess you have some bug in source or logic. The easiest way to track it would be finding it yourself or sharing details here.

1 Like

try using %d I think codechef works same on %d and %lls.

1 Like

@mohitkyadav the time limit exceeds only when the program is too slow and does not fit in the time limit provided for the question. If your logic is correct then in most of the cases it doesn’t matter that whether you use int or long long int. At codechef, approximately 10$^8$ to 10$^9$ operations can be performed in 1 second time limit.

1 Like

I have personally seen that using too much of (long long int / unsigned long long int) does actually lead to Time Limit Exceeded ocassionally.

1 Like

If you are on windows and using mingw, gcc uses the win32 runtime, where printf needs %I64d for a 64 bit integer. (and %I64u for an unsinged 64 bit integer)

For most other platforms you’d use %lld for printing a long long. (and %llu if it’s unsigned). This is standarized in C99.

gcc doesn’t come with a full C runtime, it defers to the platform it’s running on - so the general case is that you need to consult the documentation for your particular platform - independent of gcc.

@srd091 please check your e-mail

@mukulkherli %d format specifier is used for int (4 bytes) and %lld is for long long int which is of size 8 bytes.

2 Likes

you really got me.

1 Like

you are right but.
I experienced yesterday while submitting my code in DEC16 I was really getting TLE while using %lld,
but it’s cleared when I replaced it with %d.