## Search found 147 matches

- Fri Jun 27, 2003 10:50 pm
- Forum: C++
- Topic: [Resolved]memset problems
- Replies:
**3** - Views:
**1776**

### [Resolved]memset problems

i sometimes get strange results when i try to use memset to initialize an array. if i have something like memset(arr,0,___) sometimes it doesnt initilize anything, and sometimes it initializes to strange values. what should the third parameter be? something like sizeof(int)*arraysize if my array is ...

- Fri Jun 27, 2003 4:01 am
- Forum: Algorithms
- Topic: generate all factors of a number
- Replies:
**4** - Views:
**2244**

your code is a bit slow, it check every number less than x/2 :S oo, eh my algo works some work differently. finding the smallest prime factor is simply looping from 1 to the number and take the smallest number that divides into n. looks something like this: if (X%2==0) {prime[0]=2; pcnt=1;} do{X/=2;...

- Thu Jun 26, 2003 6:00 pm
- Forum: Volume 1 (100-199)
- Topic: 124 - Following Orders
- Replies:
**49** - Views:
**7434**

- Thu Jun 26, 2003 5:37 pm
- Forum: Volume 1 (100-199)
- Topic: 124 - Following Orders
- Replies:
**49** - Views:
**7434**

A specification consists of two lines: a list of variables on one line followed by a list of contraints on the next line. the first line is just the variables. the second line is the constraints, so the onl constraints are a<b and b<f interesting, this is just like the 2003 CCC stage 2 problem day ...

- Thu Jun 26, 2003 5:31 pm
- Forum: Algorithms
- Topic: generate all factors of a number
- Replies:
**4** - Views:
**2244**

- Wed Jun 25, 2003 10:46 pm
- Forum: Algorithms
- Topic: generate all factors of a number
- Replies:
**4** - Views:
**2244**

### generate all factors of a number

Hi This problem (generating all factors of a number) occurs constantly in programming. i have a tedius way of doing it but i want to know if its a better and faster way. first we create an array with just 1 in it. its going to contain all the factors of N in the end. find the smallest prime factor t...

- Wed Jun 25, 2003 3:14 pm
- Forum: Algorithms
- Topic: help with one "usaco hard problem" ... please.....
- Replies:
**19** - Views:
**9755**

for contact, you gotta deal with 01, and 001, which all has a binar value of 1 so the best way is to add 1 in the front, ie 101 and 1001 just walk through the input data, keep track of the longest block you need (ie if the input asks you for something at most length 16, just keep track of 16 most re...

- Tue Jun 24, 2003 7:42 pm
- Forum: Volume 1 (100-199)
- Topic: 194 - Triangle
- Replies:
**22** - Views:
**4672**

### Help: 194 - WA [Resolved]

i am 99% i got all my cases covered but i am still getting WA. obviously i am missing something. anyone if you could point it out that would be great. i made tolerances so that when i test for equality, i am actually testing the absolute value of diff<0.0000001 first i made sure all the angles and s...

- Sat Jun 14, 2003 9:30 pm
- Forum: Volume 103 (10300-10399)
- Topic: 10346 - Peter's Smokes
- Replies:
**46** - Views:
**16603**

- Sat Jun 14, 2003 2:40 am
- Forum: Volume 6 (600-699)
- Topic: 674 - Coin Change
- Replies:
**77** - Views:
**26585**

### 674

in problem 674, I am the only one who's run time is exactly 0.00.674!

- Fri Jun 13, 2003 11:29 pm
- Forum: Algorithms
- Topic: Longest Increasing Subsequence
- Replies:
**2** - Views:
**2153**

- Fri Jun 13, 2003 11:28 pm
- Forum: Algorithms
- Topic: Find second min number .
- Replies:
**10** - Views:
**4387**

Hi Moni,

cant you just keep track of the two smallest numbers you find? like this:

cant you just keep track of the two smallest numbers you find? like this:

Code: Select all

```
for (i=0;i<n;i++){
if (arr[i]<num1) {num2=num1;num1=arr[i];}
else if (arr[i]<num2) num2=arr[i];
}
```