Questions tagged [time-limiting]
128 questions
-2
votes
3 answers
C# - Wait for Task with return value
I want to have a code block, which should be executed with a maximum time limit. If the functions hangs, it should be aborted.
From this question I adapted the following solution:
public static void ExecuteWithTimeLimit(int timeLimit_milliseconds,…

Pixel_95
- 954
- 2
- 9
- 21
-2
votes
1 answer
Does an algorithm exist that converts a (base 10) number to into another number for any base in constant time?
I am solving a problem where I am given three integers (a,b,c), all three can be very large and (a>b>c)
I want to identify for which base between b and c, produces the smallest sum of digits, when we convert 'a' to that base.
For example a = 216,…

Patrick_Chong
- 121
- 7
-2
votes
1 answer
The Chinese clock problem c++ (giving me time limit error)
I have been trying to solve this problem for an online judge system, which requires a time limit of 1000ms. I have tried a few variations of solutions, but I will post my best draft here. I was able to get my answers right, however, I am exceeding…
-2
votes
2 answers
Question is to find two numbers within 1 to num that multiply to become num
t=int(input())
while t > 0:
num=int(input())
lst=[]
n=0
for i in range(1,math.floor(math.sqrt(num))+1):
if num%i==0:
lst.append(i)
n=len(lst)
if n == 1:
print(1,num)
else:
…

Chandrachud Pati
- 425
- 1
- 5
- 12
-2
votes
1 answer
How do I avoid TLE in codes like this?
Most of my codes face similar problems. How do I fix it?.
Problem here: http://usaco.org/index.php?page=viewproblem2&cpid=692
#include
#include
#include
using namespace std;
string rotate_s(string s){
int m=…

GrGr11
- 1
- 3
-2
votes
1 answer
Most Frequent Digit In a Specific Range
First of all: before you downgrade THIS IS NOT MY HOMEWORK, this question belongs to codingbat or eulerproject or another website. I am NOT asking you to give me a fully completed and coded answer I am asking you to give me some ideas to HELP…

doppler
- 53
- 1
- 1
- 6
-2
votes
2 answers
Time Limit Exceeding for spoj CANDYSTN
#include
using namespace std;
int main()
{
long long int i,a,b,arr[10000]={0},dif,sum=0,tem=1,t;
cin>>t;
for(int m=0;m>a>>b;
for(i=0;i

Nalin
- 1
- 2
-3
votes
3 answers
Quickest way to iterate in a C++ vector
I was looking for some tips regarding vector iteration.
I am trying to fulfill a challenge, in which you have to implement a function (SumOfTwo) that takes two vectors and a sum as arguments and has to check if there is any pair of numbers in the…

Cooli
- 169
- 3
- 14