Questions tagged [time-limiting]
128 questions
0
votes
1 answer
In socket programming using C language, how to set time limit on server for accepting client to establish connection?
I'm developing an application which involves 1 client and 1 server.
I want the server to listen for only 5 seconds for a connection. If the client is not attempting to establish a connection then the sever should stop listening and return an error…
0
votes
3 answers
How to reduce this piece of code in order to avoid TLE
The program is to find the number of digits in a factorial of a number
#include
#include
int main()
{
int n = 0 , i , count = 0 , dig ;
double sum = 0, fact;
scanf("%d" , &n );
for(i=1;i<=n;i++)
{
sum = sum + log(i);
}
fact =…

Aryan Shah
- 1
- 1
0
votes
1 answer
Is there a way to put a time limit to fgets()?
I'm running a console using fgets() in a microcontroller. If I leave the console idle for too much time while fgets() is prompting for commands the watchdog timer would get triggered.
I wonder if it is possible to set a time limit on fgets() so…

Marco Ramirez Castro
- 316
- 2
- 5
- 23
0
votes
1 answer
How to display a solution with using timelimit in CPLEX for scheduling(CP)
Now I am trying to get a solution within a specific time-limit in my code.
Actually, my problem(scheduling) is NP-hard.
It spends lots of time to get a solution or out of memory.
So, I set a time-limit in my code(60s) and I'd like to get a…

sangho park
- 25
- 4
0
votes
3 answers
Limit The User Login To Specific Time Period
I'm making an office application and I want to limit the user to log in only on office hours. but the admin login any time

itxrahulsingh
- 53
- 1
- 11
0
votes
2 answers
How to optimize the code to avoid a time limit error
I'm creating a prog for my exam. The code works properly but i got Time Limit error. How I can write this code bettere to avoid this error?
#include
#include
#include
int main()
{
int a, sum;
float b, i;
…

Vgeorgy
- 13
- 2
0
votes
2 answers
Offer trial version for PHP software
Am wondering if anyone has any suggestions on how to offer a trial downloadable version for a PHP software. I know Kayako and many other companies do so. Any suggestions?
Thank you for your time.

Alec Smart
- 94,115
- 39
- 120
- 184
0
votes
0 answers
Avoid time limit of odd number of odd divisors
The problem set was on a contest:
Given a range [L, R], find the number of integers in that range which have an odd number of odd divisors. For example, 1 has only one divisor and it is odd, 9 has three divisors {1, 3, 9} and all of them are odd.…

Parag
- 9
- 1
0
votes
1 answer
codeforces timelimit (230B T-primes) python3.6
I have a problem with my code, I use the eratosthenes this function to create a list, and I just make a big memory size list (1000000), in the main I input the codeforces input() and let them sqrt(), so, I dont know why my code timelimit over than…

Daniel kuo
- 43
- 1
- 9
0
votes
1 answer
TimeLimitExceeded upon submission
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
class Main {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader input = new…

DCodes
- 789
- 1
- 11
- 27
0
votes
2 answers
Need more Efficient way to read subarrays
The problem statement asks the number of such subarrays where i < j < k, such that sum of any two numbers should be greater than or equal to the third in the subarray:
What I did:
I ran a loop from i=0 till n-2:
and the basic logic I used was if…

Behl
- 129
- 10
0
votes
0 answers
Python3 Exceed time limit when finding prime number using square root method
I'm trying to write in python3 to determine whether a number is a prime number or not.
I was specifically demanded to only use the following method:
"Divide the input with all the positive prime number smaller than it's square root."
For example, if…

Aimee
- 345
- 1
- 2
- 9
0
votes
1 answer
How to take space separated input in Java using BufferedReader?
How to take space separated input in Java using BufferedReader?
Please change the code accordingly, i wanted the values of a, b, n as space seperated integers and then I want to hit Enter after every test cases.
Which means first i'll input the…

Muktadir Khan
- 148
- 3
- 17
0
votes
1 answer
limited-time control in trun-based game [node.js]
I'm creating a card game like Crazy Eights. And I already publish prototype.
Look here http://himapoyo.com
And next, I want to implement limited-time(5 seconds per a turn) If turn-player don't play, I wanna make server skip its player. I write the…

Taro Yamada
- 23
- 4
0
votes
0 answers
Set CPU time limit for process in Linux
I'm using setrlimit(2) to set process' CPU time limit with option RLIMIT_CPU. However, I noticed that idle time do not counts for this option. For example, if you sleep(3) forever, you'll never get SIGKILLed. I need processes calling sleep(3) to get…

matheuscscp
- 827
- 7
- 23