C++能过, G++RE ,弃疗了...

#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#define n 6

using namespace std;

int num[15];
int dp[200000];

int main  ( )
{
    int c = 1;
    while ( ~scanf ( "%d" , &num[1] ) )
    {
        int sum = 0;
        for ( int i = 2 ; i <= n ; i++ ) scanf ( "%d" , &num[i] );
        for ( int i = 1 ; i <= n ; i++ ) sum += num[i]*i;
        if ( sum == 0 ) break;
        printf ( "Collection #%d:\n" , c++ ); 
        if ( sum &1 ) 
        {
            puts ( "Can't be divided." );
            puts ( "");
            continue;
        }
        sum >>=1;
        memset ( dp , 0 , sizeof ( dp ) );
        dp[0] = 1;
        for ( int i = 1 ; i <= n ; i++ )
        {
            if ( i*num[i] >= sum )
            {
                for ( int j = i ; j <= sum ; j++ )
                   if ( dp[j-i] ) dp[j] = 1;
                continue;
            }
            int k = 1;
            while ( k < num[i] )
            {
                for ( int j = sum ; j >= k*i ; j-- )
                    if ( dp[j-k*i] ) dp[j] = 1;
                num[i] -= k;
                k <<= 1;
            }
            for ( int j = sum ; j >=num[i]*i ; j-- )
                if ( dp[j-num[i]*i] ) dp[j] = 1;
        }
        if ( dp[sum] ) puts ( "Can be divided." );
        else puts ( "Can't be divided." );
        puts ( "" );
    }
}