Using scanf in C programs is faster than using cin I just spent an evening working on a problem on UVa Online Factovisors, a very interesting problem, check it out http uva. Itemid8 category3. I was getting TLE time limit exceeded on my submissions. On these problem solving online judge sites, you have about a 2 3 second time limit to handle potentially thousands of test cases used to evaluate your solution. For computationally intensive problems like this one, every microsecond counts. I was using the suggested algorithm read about in the discussion forums for the site, but was still getting TLEs. I changed just cin n m to scanf d d, n, m and the few tiny couts to printfs, and my TLE turned into Accepted So, yes, it can make a big difference, especially when time limits are short. Code, Example for Program to find first occurrence of a string in another string in C Programming. Use of getch,getche and getchar in C, Clear Explanation, getch Example,getche example,getchar example.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
November 2017
Categories |