## Search found 134 matches

Wed Nov 08, 2006 6:57 am
Forum: Algorithms
Replies: 1
Views: 1429

we have n numbers in a set A A = {a1, a2, a3 ... an} and a number s. I want to pick up some numbers from A, and sum of these numbers will equals to s or closest to s(but smaller than s). input: 3 1 2 7 9 output: 2 7 input: 3 1 2 7 5 output 1 2 Can I solve this problem using dynamic programming? Than...
Wed Jul 27, 2005 6:39 pm
Forum: Volume 3 (300-399)
Topic: 336 - A Node Too Far
Replies: 121
Views: 41884
CDiMa,thank u indeed,u helped me a lot.
I've correct my code,but it still get WA.but i hope i can find the mistakes myself.
Anyway,thanks again :)
Wed Jul 27, 2005 2:12 pm
Forum: Volume 3 (300-399)
Topic: 336 - A Node Too Far
Replies: 121
Views: 41884
I've understand what's wrong with my code Thank u,MDima but here's another problem,my code always get TLE now i even change my graph data structure from adj matrix to adj list,but still got TLE,can u tell me why? is there any wired input data in test case?like a node presented by a string? #include ...
Wed Jul 27, 2005 12:59 pm
Forum: Volume 3 (300-399)
Topic: 336 - A Node Too Far
Replies: 121
Views: 41884
yeah,it's dfs,actually.
but it isnt why i got WA,is it?
Tue Jul 26, 2005 2:29 pm
Forum: Volume 3 (300-399)
Topic: 336 - A Node Too Far
Replies: 121
Views: 41884
CDiMa,i'm afraid ur code is wrong just look at this group of input and output u apply to us 5 1 2 2 3 3 1 4 5 6 2147483647 1 1 ur program's output is 5 which should be 4 isn't it? and i also got WA,hope someone can help me out i used a function int lookup(int n) { int i; for(i = 0;i < numOfNodes;i++...
Tue Feb 15, 2005 6:01 pm
Forum: Volume 100 (10000-10099)
Topic: 10013 - Super long sums
Replies: 212
Views: 42099

### 10013 Super Long Sums Why WA?

I've read all topics concerning 10013,but still don't know why i got WA. can anyone help me? #include <cstdio> #include <cmath> using namespace std; #define MAXDIGITS 1000101 /* maximum length bignum */ typedef struct { char digits[MAXDIGITS]; /* represent the number */ long lastdigit; /* index of h...
Tue Feb 15, 2005 3:18 pm
Forum: Volume 107 (10700-10799)
Topic: 10773 - Back to Intermediate Math
Replies: 41
Views: 17474
i know why i keep getting WA

the input must be weird

i deleted my while(cin >> N) loop and got AC

but i still don't know why

if there's something following the input case ,i should get TLE but not WA
:-?
Tue Feb 15, 2005 10:10 am
Forum: Volume 107 (10700-10799)
Topic: 10773 - Back to Intermediate Math
Replies: 41
Views: 17474
i don't think so.

i've changed my code to if(u == 0 || u <= v) printf("Case %d: can't determine\n",i);

but still got WA
Mon Feb 14, 2005 6:45 pm
Forum: Volume 107 (10700-10799)
Topic: 10773 - Back to Intermediate Math
Replies: 41
Views: 17474

### 10773 Back to Intermediate Math WA,i'm totally confused:(

#include <iostream> #include <cmath> #include <cstdio> using namespace std; int main() { int N; double d,v,u; while(cin >> N) { for(int i = 1;i <= N;i++) { cin >> d >> v >> u; if(v == 0 || u == 0 || u <= v) ... else { ... } } } return 0; } a quite simple problem,huh?why do i keep getting WA???
Fri Feb 11, 2005 4:11 pm
Forum: Volume 4 (400-499)
Topic: 481 - What Goes Up
Replies: 82
Views: 15021
yeah,that's why i got WA.
thank u so much!
Mon Jan 31, 2005 4:24 pm
Forum: Volume 4 (400-499)
Topic: 481 - What Goes Up
Replies: 82
Views: 15021

### 481 Why WA?

i used the DP(LIS) which is O(n^2),that algorithm may cause TLE,but why i got WA? is my algorithm okay? #include <iostream> using namespace std; int height[10000]; int len[10000]; int pre[10000]; int limit; int i,j; int maxlen; int tail; void output(int i) { if(pre[i] == -1) { cout << height[i] << e...
Wed Oct 06, 2004 7:51 pm
Forum: Volume 3 (300-399)
Topic: 350 - Pseudo-Random Numbers
Replies: 56
Views: 17038

### 350 is my algorithm wrong

[cpp] #include <iostream> using namespace std; int arr[10001];//used to flag whether a number has been visited int get(int z,int i,int m,int l) { //before the while() loop is initial int count = 0; for(int t = 0;t < 10001;t++) { arr[t] = 0; } arr[l] = 1; while(1) { count++; l = (z * l % m + i % m) %...
Tue Oct 05, 2004 4:19 pm
Forum: Volume 3 (300-399)
Topic: 332 - Rational Numbers from Repeating Fractions
Replies: 83
Views: 21204
I've gotten AC,thanks
Tue Oct 05, 2004 4:02 pm
Forum: Volume 3 (300-399)
Topic: 332 - Rational Numbers from Repeating Fractions
Replies: 83
Views: 21204
[cpp]
#include <iostream.h>
int main()
{
double d = 0.987654321;
cout << (long long)(1000000000 * d) << endl;
return 0;
}
[/cpp]

the output would be:

98654320

that's why i always get wrong answer.
but how can i control it?
is there any type that be preciser than double?
Tue Oct 05, 2004 11:31 am
Forum: Volume 1 (100-199)
Topic: 154 - Recycling
Replies: 29
Views: 3550
yeah,i got what u mean,they are not in order,now i got AC.Thanks