Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

YOOOOOOOOOOOOOOOOOOOOOO

Name: Anonymous 2010-10-12 22:27

c++ find the power set of a set containing 40 integers in polynomial time

Name: c++ 2010-10-12 22:34

Stop pestering me with your stupid questions, ``fagcake''.

Name: Anonymous 2010-10-12 23:15

Do your own homework.

Name: Anonymous 2010-10-12 23:51

You can do that in constant time.

Name: Anonymous 2010-10-13 0:15

You can do that in Swatch® Internet Time

Name: Anonymous 2010-10-13 1:51

// anus.cpp
// @author [YOUR NAME HERE]
// Reads a set of forty numbers from command line arguments
// and prints each element of the power set
#include <cstdlib>
#include <cstdio>
#include <vector>
#include "anus.h" // Left as an exercise to the reader

static int FORTY = 40;

vector<int>* build_subset(vector<int> &set, vector<bool> &bits) {
  vector<int> *result = new vector<int>;
  for(int i=0; i < bits.size(); i++) {
    if (bits[i]) {
      result->push_back(set[i]);
    }
  }
  return result;
}

void print_subset(vector<int>* subset) {
  printf("[");
  for(int i=0; i < subset->size(); i++) {
    int n = subset->at(i);
    printf("%d ", n);
  }
  printf("]\n");
}

using std::cout;
using std::endl;
int main(int argc, char* *argv) {
  if (argc < FORTY+1){
    printf("Usage: anus [first number] [second number] .. [40th number]\n");
    return 1;
  }

  vector<int> set;
  for (int i=1; i < FORTY+1; i++) {
    set.push_back(atoi(argv[i]));
  }
 
  // empty set
  vector<bool> empty(FORTY, false);
  print_subset(build_subset(set, empty));

  long propersubsets = 1099511627776L; // 2 ^ 40
  for (long i=0; i < propersubsets; i++) {
    vector<bool> bits;
    for (long j=0; j < FORTY; j++) {
      bool on = ((i & j) == j);
      bits.push_back(on);
    }
    print_subset(build_subset(set, bits));
  }
}


Here you go, OP. You'll notice that this algorithm's runtime depends only on a constant. Your professor will be thrilled that you've discovered a better-than-polynomial time algorithm.

Name: VIPPER 2010-10-13 5:25

>>6
This looks like JEWS code.

Name: VIPPER 2010-10-13 8:41

>>7
LOOK, I SAID JEWS, I'M SOOOO EDGY.

Name: VIPPER 2010-10-13 9:26

>>8
Yes VIPPER.

Name: Anonymous 2010-11-06 1:58

Way to be a dick, dick.

Name: Anonymous 2010-11-06 2:02

[][url]http://example.com/[/url].b.i Bold italic link![/]

Name: Anonymous 2010-11-06 6:15

c++ find the power set of a set containing 40 integers in polynomial time

polynomial time

power set contains 2^N elements. There is no way to print 2^N elements in N^const time

IHBT

Name: Anonymous 2010-11-06 7:48

>>12
printing a constant number of integers
not polynomial time

IHBT

Name: Anonymous 2011-02-02 22:55

Name: Anonymous 2013-01-19 23:06

/prog/ will be spammed continuously until further notice. we apologize for any inconvenience this may cause.

Name: 2013-01-25 17:50

葴䙈䈀ࡈ或蝩吤✡䘧払倧ȇ䈄䐆䈈抔熇㐢桅䁸䑄ॠᝰ扠ᕱㄷ牳易朙襷Β鐨鑀ᙱ撁ᔗざ捂腙䈧㜐ㄩㄘŨㅃㅇ捉礑蚘ࡰ艗吨怓砖暙↉ᅇِ然鄰䥦䤇楕⦘怰ᖒ數䅅墒吗牧Aᜨሴ┈夙⚉焄ᥳ聠唆ޘ呙☑夃梉ɲ朁㌰晐打礳 㘳ᔸᄥ祣璃䜰㙹⊗ޒ児㈂㔕蝥䔆遇逤䥁蔂艙㞙㉅㤘慹爄衄ᐆうሴ⥔鍔愴䠓莅䑐鄩䂃䊃獗荒Р牆ݔ㌄㕙録䅶鞗鄱㌱鎂焐䖈̢ᙧ䒔犖楆ᡥ⍒阵共搹劀鍐癕甇猁䘸圗怙周杖ᤧ炔㔓蕅暀嚅႗㈑瘢”鍣饂肓噥䍅ᚂኖउᦘ▀茈祳奦喆阳䄆呰嘹➉搕ᅢ梆ࠐ桗疐㘥蝕聑蝡ℒኘ扱․隘慢U㍉䊂煶ࠥ㊉昀ᐃ㥀搦卑錕吰ءز䀨坄ص蔣逗㘂蜰瑀蝥锕℘⎈㥗ᘁ的ᤤ蘗┵P⌙嘢〕們蔔㈡࢐碇㦙ᙡ邒ᙧ牰㉲褶Ι熑䝁票㉢邃褲≐朒癦䝧怅肓䥕ざ杗逡鄥ɕᄧ㡉禆䢑║♣戧䁠⅕Ƅ妅灤㝹愧℥䈢煄月و堄襰荒Ԇ脦ᑗ䌶䉨⑓䘉ी㝣㉇葦朖Ⅰ刖蔩⚁䑥達ᔗ▙阨㠶Ԃ♈煨䜈䆒唤œ偤䤕袄Ɖঅ䝖匴䂇⁨ɤ卷榘ȴ愲г嘂ㅵ甇栕蚖঑栩蒁搑鍆葄㚒፶㝕兵琢䢅收㥔坧䡂递c墆钇㡉恈㡄怓㙇ᆃ莓蚐頠।锴⤤㜵ᡧ耹萂ࠨ摃䠁灄蕙塥ↅㄖ萴肀㆖噂衠▔䒕退聓嘵礧暒愷畡摅㐤䔗ٸ愂㔀鎗⎗Ֆၒ⠦न礐坉昃ᥩ虂卅ᡀ先舑刂ၹ䚈ᕓ脠摩睐㑔⡠䅠ࡕȘ慦᝹㝕啶ܤ萔董ᤓ➇琙鉖睸莆昘送塤嘨荧鄔眗䝥䕴㘷▆♷遈ᐗ䜤萤☧堠熐♈䂁䁔啲䜒斕぀挄䁘遂疖楶䅴爃猨戙ᦙ䔘➈肅蜀鞖饷䝙၄㑴遁甓

Don't change these.
Name: Email:
Entire Thread Thread List