×

# PRIME1: TLE on long long and AC on int

 0 Using the same code, if I use the long long data type it shows TLE and if the data type ONLY is changed to int then it gets AC. Moreover, the constraints' values are not in the int range.. Problem: PRIME1 Solution: Using int AC Solution: Using long long TLE asked 07 Jan, 01:52 0●1 accept rate: 0% the intended solution is segmented sieve. Using long long/int will not matter if you use that logic. Your brute solution with int just passed luckily :P (08 Jan, 01:18)

 0 Which problem are you discussing, please share problem link.and your solution link to check the issue.(Provided that the problem should not be of any ongoing contest.) answered 07 Jan, 04:20 56●4 accept rate: 0% added the required links (07 Jan, 20:04) Sometimes using operation like % on long long takes more time than on int numbers, because long long is 64 bit ,while int is 32 bit. (07 Jan, 23:58)
 0 This doesn't usually happen, but only when the time limits are too strict and constraints quite high. There's higher chance of getting into such a problem when your code involves a lot of modulo operations and data structures (like sets) that involve operations of long integers in the comparator function, though the chance of running into TLE is low even then. I usually use this #define int long long in the contest to save time I have almost never encountered such issues (except during some practice problems on spoj, though the problems were intentionally designed so). answered 08 Jan, 01:06 114●6 accept rate: 0%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×715
×69