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 ...
Search found 134 matches
- Wed Nov 08, 2006 6:57 am
- Forum: Algorithms
- Topic: Optimizing Loading Problem
- Replies: 1
- Views: 1817
- Wed Jul 27, 2005 6:39 pm
- Forum: Volume 3 (300-399)
- Topic: 336 - A Node Too Far
- Replies: 121
- Views: 58646
- Wed Jul 27, 2005 2:12 pm
- Forum: Volume 3 (300-399)
- Topic: 336 - A Node Too Far
- Replies: 121
- Views: 58646
- Wed Jul 27, 2005 12:59 pm
- Forum: Volume 3 (300-399)
- Topic: 336 - A Node Too Far
- Replies: 121
- Views: 58646
- Tue Jul 26, 2005 2:29 pm
- Forum: Volume 3 (300-399)
- Topic: 336 - A Node Too Far
- Replies: 121
- Views: 58646
- Tue Feb 15, 2005 6:01 pm
- Forum: Volume 100 (10000-10099)
- Topic: 10013 - Super long sums
- Replies: 212
- Views: 67711
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 ...
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 ...
- Tue Feb 15, 2005 3:18 pm
- Forum: Volume 107 (10700-10799)
- Topic: 10773 - Back to Intermediate Math
- Replies: 41
- Views: 23864
- Tue Feb 15, 2005 10:10 am
- Forum: Volume 107 (10700-10799)
- Topic: 10773 - Back to Intermediate Math
- Replies: 41
- Views: 23864
- Mon Feb 14, 2005 6:45 pm
- Forum: Volume 107 (10700-10799)
- Topic: 10773 - Back to Intermediate Math
- Replies: 41
- Views: 23864
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 ...
- Fri Feb 11, 2005 4:11 pm
- Forum: Volume 4 (400-499)
- Topic: 481 - What Goes Up
- Replies: 82
- Views: 27833
- Mon Jan 31, 2005 4:24 pm
- Forum: Volume 4 (400-499)
- Topic: 481 - What Goes Up
- Replies: 82
- Views: 27833
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 ...
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 ...
- Wed Oct 06, 2004 7:51 pm
- Forum: Volume 3 (300-399)
- Topic: 350 - Pseudo-Random Numbers
- Replies: 56
- Views: 23291
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 ...
#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 ...
- Tue Oct 05, 2004 4:19 pm
- Forum: Volume 3 (300-399)
- Topic: 332 - Rational Numbers from Repeating Fractions
- Replies: 83
- Views: 34222
- Tue Oct 05, 2004 4:02 pm
- Forum: Volume 3 (300-399)
- Topic: 332 - Rational Numbers from Repeating Fractions
- Replies: 83
- Views: 34222
- Tue Oct 05, 2004 11:31 am
- Forum: Volume 1 (100-199)
- Topic: 154 - Recycling
- Replies: 29
- Views: 6206