hab ihm zugeguckt beim coden!!!!!!!!
Beiträge von Wieso wurde ich gebannt?
-
-
Porque? Si amigo espanêlo!!!!
-
hört pls mit mobbing auf kommt 1. mai berlin kreuzberg, eskalation!!!!!!!!!
-
oben steht 100% by by me lern lessen
-
PUSH ED ! " §33333
-
Man ey immer die Nazis halo ich komme aus mexiko ich kan nicht gut deuts DU NAZI
-
100% by me coded in c+++
[hide]PHP
Alles anzeigen#include <iostream> #include <sstream> #include <string> #include <vector> #include <deque> #include <queue> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> using namespace std; class CarrotBoxes { int n; vector< vector<int> > adj; public: double theProbability(vector <string> info) { n = info.size(); adj.resize(n); for(int i=0; i<n; i++){ adj[i].resize(n); for(int j=0; j<info[i].length(); j++) adj[i][j] = (info[i][j] == 'Y') ? 1 : 0; } FloydWarshall( ); vector<int> comp(n); StronglyConnectedComponents(comp); /* Encontra as fontes (grau de entrada = 0) */ vector<int> indeg(n); for(int i=0; i<n; i++){ if(comp[i] != i) continue; for(int j=0; j<n; j++) indeg[j] += (adj[i][j] && j != i); } /* Conta qtas fontes alcancam cada vertice */ vector<int> reach(n); for(int i=0; i<n; i++){ if(comp[i] != i || indeg[i] != 0) continue; for(int j=0; j<n; j++) if (i != j && adj[i][j]) reach[j]++; } /* Se houver uma fonte que so alcanca folha que alguma outra folha alcanca, podemos ignora-la */ int open = 0; int last = 0; for(int i=0; i<n; i++){ if(comp[i] != i || indeg[i] != 0) continue; int min_reach = n+1; for(int j=0; j<n; j++) if (i != j && adj[i][j]) min_reach = min(min_reach, reach[j]); if (min_reach == 1 || last) // Nao podemos ignorar open++; else last = 1; } return(1.0 - open*(1.0/n)); } void FloydWarshall( ){ for(int k=0; k<n; k++) for(int i=0; i<n; i++) for(int j=0; j<n; j++) adj[i][j] = max(adj[i][j], adj[i][k] * adj[k][j]); } void StronglyConnectedComponents(vector<int> &comp){ comp.assign(n, -1); for(int i=0; i<n; i++){ if(comp[i] != -1) continue; for(int j=0; j<n; j++){ if(adj[i][j] && adj[j][i]) comp[j] = i; } } } // BEGIN CUT HERE public: void run_test(int Case) { if ((Case == -1) || (Case == 0)) test_case_0(); if ((Case == -1) || (Case == 1)) test_case_1(); if ((Case == -1) || (Case == 2)) test_case_2(); if ((Case == -1) || (Case == 3)) test_case_3(); if ((Case == -1) || (Case == 4)) test_case_4(); if ((Case == -1) || (Case == 5)) test_case_5(); } private: template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); } void verify_case(int Case, const double &Expected, const double &Received) { cerr << "Test Case #" << Case << "..."; if (Expected <= Received + 1e-8 && Expected >= Received - 1e-8) cerr << "PASSED" << endl; else { cerr << "FAILED" << endl; cerr << "\tExpected: \"" << Expected << '\"' << endl; cerr << "\tReceived: \"" << Received << '\"' << endl; } } void test_case_0() { string Arr0[] = {"YYYYY", "NYNNN", "NNYNN", "NNNYN", "NNNNY"} ; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); double Arg1 = 0.8; verify_case(0, Arg1, theProbability(Arg0)); } void test_case_1() { string Arr0[] = {"YNNNN", "NYNNN", "NNYNN", "NNNYN", "NNNNY"}; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); double Arg1 = 0.2; verify_case(1, Arg1, theProbability(Arg0)); } void test_case_2() { string Arr0[] = {"Y"}; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); double Arg1 = 1.0; verify_case(2, Arg1, theProbability(Arg0)); } void test_case_3() { string Arr0[] = {"YNNNN", "YYNNN", "YNYNN", "NNNYY", "NNNYY"} ; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); double Arg1 = 0.6; verify_case(3, Arg1, theProbability(Arg0)); } void test_case_4() { string Arr0[] = {"YYYNNNYN", "NYNNNNYN", "NNYNNNNN", "NYNYNNNN", "YNNNYNNY", "NNYNNYNN", "NNNNYNYN", "NNYNNNNY"} ; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); double Arg1 = 0.875; verify_case(4, Arg1, theProbability(Arg0)); } void test_case_5() { string Arr0[] = {"YNNNNNNNNYNNNNNNNNNN", "NYNNNNNNNNNNNNNNNNNN", "NNYNNNNNNNYNNNNNYNNN", "NNNYNYNNNNNNNNYNNNNN", "NNNNYNNNNNNNNNYNNNNY", "NNNNNYNNNNNNNNNNNNNY", "NNNNYNYNYNNNNNNNNNNN", "NNNNNNNYNNNYYNNNNNNN", "NNNNNNNNYNNNNNNNNNNN", "YNNNNNNNNYNNNNNYNNNN", "NNNNNNNNNNYNNNNNNNNN", "NYNNNNNNNNNYNNNNNNNN", "NNNNNNNYNNNNYNNNNNNN", "NNNNNNNNNNNNNYNNNYNN", "NNNNNNNNNNNYNNYNNNYN", "NYNNNNNNNNNNNNNYNNNN", "NNYNNNNNNNNNNNNNYNNN", "NNNNNNNNNNNNNYNYNYNN", "NNNNNNNNYNYNNNNNNNYY", "NNNYNNNNNNNNNNNNNNNY"}; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); double Arg1 = 0.75; verify_case(5, Arg1, theProbability(Arg0)); } // END CUT HERE }; // BEGIN CUT HERE int main() { CarrotBoxes ___test; ___test.run_test(-1); } // END CUT HERE
[/hide]
-
100% gecoded unerstelt von mir!!!!!!!!!!!!!!!!!!!!!!
[hide]Spoiler anzeigen
PHPfunction image_resize_dimensions($source_width,$source_height,$thumb_width,$thumb_height) { $source_ratio = $source_width / $source_height; $thumb_ratio = $thumb_width / $thumb_height; // Ratio is Taller if ($thumb_ratio > $source_ratio) { $result_height = $thumb_height; $result_width = $thumb_height * $source_ratio; } // Ratio is Wider elseif ($thumb_ratio < $source_ratio) { $result_width = $thumb_width; $result_height = $thumb_width / $source_ratio; } // Ratio the Same elseif($thumb_ratio == $source_ratio) { $result_height = $thumb_height; $result_width = $thumb_width; } return array('x'=>$result_width,'y'=>$result_height); } /* ----------[ func IMAGE_RESIZE ]----------*/ function image_resize_jpg($image = FALSE, $filename = FALSE, $thumb_width, $thumb_height, $maximize = FALSE, $quality = 75, $image_object = FALSE) { if (is_resource($image_object) === true) { $source_width = imagesx($image_object); $source_height = imagesy($image_object); $thumb_source = $image_object; } else { list($source_width, $source_height, $source_type) = @getimagesize($image); switch($source_type) { case 1: $thumb_source = imagecreatefromgif($image); break; case 2: $thumb_source = imagecreatefromjpeg($image); break; case 3: $thumb_source = imagecreatefrompng($image); break; default: return false; break; } } if ($maximize === TRUE) { $target_width = $thumb_width; $target_height = $thumb_height; if ($thumb_width && ($source_width < $source_height)) { $thumb_width = ($thumb_height / $source_height) * $source_width; } else { $thumb_height = ($thumb_width / $source_width) * $source_height; } if ($thumb_height < $target_height) { $multiply_height = $target_height / $thumb_height; $thumb_height = $thumb_height * $multiply_height; $thumb_width = $thumb_width * $multiply_height; } if ($thumb_width < $target_width) { $multiply_width = $target_width / $thumb_width; $thumb_height = $thumb_height * $multiply_width; $thumb_width = $thumb_width * $multiply_width; } $thumb_height = ceil($thumb_height); $thumb_width = ceil($thumb_width); } else if ($source_width > $thumb_width or $source_height > $thumb_height) { $dimensions = image_resize_dimensions($source_width,$source_height,$thumb_width,$thumb_height); $thumb_width = $dimensions['x']; $thumb_height = $dimensions['y']; $target_width = $dimensions['x']; $target_height = $dimensions['y']; } else // Resize Nothing { $thumb_width = $source_width; $thumb_height = $source_height; $target_width = $source_width; $target_height = $source_height; } $thumb_image = imagecreatetruecolor($thumb_width,$thumb_height); //imagecopyresampled($thumb_image, $thumb_source, 0, 0, 0, 0, $thumb_width, $thumb_height, $source_width, $source_height); fastimagecopyresampled($thumb_image, $thumb_source, 0, 0, 0, 0, $thumb_width, $thumb_height, $source_width, $source_height); $target_image = imagecreatetruecolor($target_width,$target_height); imagecopy ($target_image, $thumb_image, 0, 0, ($thumb_width - $target_width)/2, ($thumb_height - $target_height)/2, $target_width , $target_height); if($filename === FALSE) { unset($thumb_image); return array('file'=>$filename, 'width'=>$target_width, 'height'=>$target_height, 'quality'=>$quality, 'type'=>$source_type, 'object'=>$target_image ); } else { imagejpeg($target_image,$filename,$quality); unset($target_image,$thumb_image); return array('file'=>$filename, 'width'=>$target_width, 'height'=>$target_height, 'quality'=>$quality, 'type'=>$source_type ); } } function fastimagecopyresampled (&$dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h, $quality = 3) { // Plug-and-Play fastimagecopyresampled function replaces much slower imagecopyresampled. // Just include this function and change all "imagecopyresampled" references to "fastimagecopyresampled". // Typically from 30 to 60 times faster when reducing high resolution images down to thumbnail size using the default quality setting. // Author: Tim Eckel - Date: 12/17/04 - Project: FreeRingers.net - Freely distributable. // // Optional "quality" parameter (defaults is 3). Fractional values are allowed, for example 1.5. // 1 = Up to 600 times faster. Poor results, just uses imagecopyresized but removes black edges. // 2 = Up to 95 times faster. Images may appear too sharp, some people may prefer it. // 3 = Up to 60 times faster. Will give high quality smooth results very close to imagecopyresampled. // 4 = Up to 25 times faster. Almost identical to imagecopyresampled for most images. // 5 = No speedup. Just uses imagecopyresampled, highest quality but no advantage over imagecopyresampled. if (empty($src_image) || empty($dst_image)) { return false; } if ($quality <= 1) { $temp = imagecreatetruecolor ($dst_w + 1, $dst_h + 1); imagecopyresized ($temp, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w + 1, $dst_h + 1, $src_w, $src_h); imagecopyresized ($dst_image, $temp, 0, 0, 0, 0, $dst_w, $dst_h, $dst_w, $dst_h); imagedestroy ($temp); } elseif ($quality < 5 && (($dst_w * $quality) < $src_w || ($dst_h * $quality) < $src_h)) { $tmp_w = $dst_w * $quality; $tmp_h = $dst_h * $quality; $temp = imagecreatetruecolor ($tmp_w + 1, $tmp_h + 1); imagecopyresized ($temp, $src_image, $dst_x * $quality, $dst_y * $quality, $src_x, $src_y, $tmp_w + 1, $tmp_h + 1, $src_w, $src_h); imagecopyresampled ($dst_image, $temp, 0, 0, 0, 0, $dst_w, $dst_h, $tmp_w, $tmp_h); imagedestroy ($temp); } else { imagecopyresampled ($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h); } return true; } ?>
[/hide]
-
-