Submission #16061

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
160612015-08-14 04:45:18kaTkaHr배낭 문제 준비하기 (GA9_invknapsack)C++98
Compilation error
0 ms0 KiB
#include<stdio.h>
#include<vector>
using namespace std;
typedef long long ll;
ll D[305][305];
int K = 300;
vector<int> L;
void add(int x)
{
int s = L.size(), e = s + 1;
for (int i = 0; i <= K; i++) D[e][i] = D[s][i];
for (int i = x; i <= K; i++) D[e][i] += D[s][i-x];
L.push_back(x);
}
int main()
{
ll R;
scanf("%lld", &R);
D[0][0] = 1;
for(int i = 1; i <= K; i *= 2){
add(i);
}
while(D[L.size()][K] + D[L.size()][K-1] <= R) add(1);
while(D[L.size()][K] != R){
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

invknapsack.cpp: In function ‘int main()’:
invknapsack.cpp:38:31: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘std::vector<int>::size_type {aka long unsigned int}’ [-Wformat=]
  printf("%d %d\n", L.size(), K);
                               ^
invknapsack.cpp:39:14: error: range-based ‘for’ loops are not allowed in C++98 mode
  for(int c : L) printf("%d ", c);
              ^
invknapsack.cpp:24:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &R);
                   ^