Search Results

Search found 10 results on 1 pages for 'peiska'.

Page 1/1 | 1 

  • Help solving a error in openGL

    - by peiska
    Hi, I am making a group work in openGL, and when i try to open the file that my partner gave me i have this error: -------------- Build: Debug in CG --------------- Linking console executable: bin/Debug/CG ld: library not found for -lGL collect2: ld returned 1 exit status Process terminated with status 1 (0 minutes, 0 seconds) 0 errors, 0 warnings I've seen the same code working in his computer. Is it cause he is working in Windows? and i am working in MacOSX? I am using CodeBlocks IDE. Can anyone help me solving this?

    Read the article

  • algorithm to combinatorics

    - by peiska
    I am trying to solve a combinatorics problem, it seems easy, but i am having some trouble with it. If i have at most X tables, and N persons to sit on the tables, Each table can have 1 to N seating places, and I can only sit persons in one side of a rectangular table( so the order how people sit matters). I want to make a code that can calculate all the distributions of seating places from 1 up to K tables. For example, if I have 12 persons and 1 table i have 479001600 ways of seating persons( thats easy to calculate I've used Factorial of 12). But if I have 12 persons and 3 tables i have 4390848000 ways of seating persons. I've tried different solutions but i was not able to find the correct one. I've tried to divided the 12 in 3, then o use factorial of the result (it didnt work), i've tried to use 12! * 3( it didn't work too). Can some one give me a tip in a algorithm that i can use?

    Read the article

  • Help to solve "Robbery Problem"

    - by peiska
    Hello, Can anybody help me with this problem in C or Java? The problem is taken from here: http://acm.pku.edu.cn/JudgeOnline/problem?id=1104 Inspector Robstop is very angry. Last night, a bank has been robbed and the robber has not been caught. And this happened already for the third time this year, even though he did everything in his power to stop the robber: as quickly as possible, all roads leading out of the city were blocked, making it impossible for the robber to escape. Then, the inspector asked all the people in the city to watch out for the robber, but the only messages he got were of the form "We don't see him." But this time, he has had enough! Inspector Robstop decides to analyze how the robber could have escaped. To do that, he asks you to write a program which takes all the information the inspector could get about the robber in order to find out where the robber has been at which time. Coincidentally, the city in which the bank was robbed has a rectangular shape. The roads leaving the city are blocked for a certain period of time t, and during that time, several observations of the form "The robber isn't in the rectangle Ri at time ti" are reported. Assuming that the robber can move at most one unit per time step, your program must try to find the exact position of the robber at each time step. Input The input contains the description of several robberies. The first line of each description consists of three numbers W, H, t (1 <= W,H,t <= 100) where W is the width, H the height of the city and t is the time during which the city is locked. The next contains a single integer n (0 <= n <= 100), the number of messages the inspector received. The next n lines (one for each of the messages) consist of five integers ti, Li, Ti, Ri, Bi each. The integer ti is the time at which the observation has been made (1 <= ti <= t), and Li, Ti, Ri, Bi are the left, top, right and bottom respectively of the (rectangular) area which has been observed. (1 <= Li <= Ri <= W, 1 <= Ti <= Bi <= H; the point (1, 1) is the upper left hand corner, and (W, H) is the lower right hand corner of the city.) The messages mean that the robber was not in the given rectangle at time ti. The input is terminated by a test case starting with W = H = t = 0. This case should not be processed. Output For each robbery, first output the line "Robbery #k:", where k is the number of the robbery. Then, there are three possibilities: If it is impossible that the robber is still in the city considering the messages, output the line "The robber has escaped." In all other cases, assume that the robber really is in the city. Output one line of the form "Time step : The robber has been at x,y." for each time step, in which the exact location can be deduced. (x and y are the column resp. row of the robber in time step .) Output these lines ordered by time . If nothing can be deduced, output the line "Nothing known." and hope that the inspector will not get even more angry. Output a blank line after each processed case.

    Read the article

  • 3-way quicksort, question

    - by peiska
    I am trying to understand the 3-way radix Quicksort, and i dont understand why the the CUTOFF variable there? and the insertion method? public class Quick3string { private static final int CUTOFF = 15; // cutoff to insertion sort // sort the array a[] of strings public static void sort(String[] a) { // StdRandom.shuffle(a); sort(a, 0, a.length-1, 0); assert isSorted(a); } // return the dth character of s, -1 if d = length of s private static int charAt(String s, int d) { assert d >= 0 && d <= s.length(); if (d == s.length()) return -1; return s.charAt(d); } // 3-way string quicksort a[lo..hi] starting at dth character private static void sort(String[] a, int lo, int hi, int d) { // cutoff to insertion sort for small subarrays if (hi <= lo + CUTOFF) { insertion(a, lo, hi, d); return; } int lt = lo, gt = hi; int v = charAt(a[lo], d); int i = lo + 1; while (i <= gt) { int t = charAt(a[i], d); if (t < v) exch(a, lt++, i++); else if (t > v) exch(a, i, gt--); else i++; } // a[lo..lt-1] < v = a[lt..gt] < a[gt+1..hi]. sort(a, lo, lt-1, d); if (v >= 0) sort(a, lt, gt, d+1); sort(a, gt+1, hi, d); } // sort from a[lo] to a[hi], starting at the dth character private static void insertion(String[] a, int lo, int hi, int d) { for (int i = lo; i <= hi; i++) for (int j = i; j > lo && less(a[j], a[j-1], d); j--) exch(a, j, j-1); } // exchange a[i] and a[j] private static void exch(String[] a, int i, int j) { String temp = a[i]; a[i] = a[j]; a[j] = temp; } // is v less than w, starting at character d private static boolean less(String v, String w, int d) { assert v.substring(0, d).equals(w.substring(0, d)); return v.substring(d).compareTo(w.substring(d)) < 0; } // is the array sorted private static boolean isSorted(String[] a) { for (int i = 1; i < a.length; i++) if (a[i].compareTo(a[i-1]) < 0) return false; return true; } public static void main(String[] args) { // read in the strings from standard input String[] a = StdIn.readAll().split("\\s+"); int N = a.length; // sort the strings sort(a); // print the results for (int i = 0; i < N; i++) StdOut.println(a[i]); } } from http://www.cs.princeton.edu/algs4/51radix/Quick3string.java.html

    Read the article

  • Can anyone give me tips how to solve this using Graphs in C or Java?

    - by peiska
    Can anyone give me tips how to solve this using Graphs in C or Java? I have a rectangular sector, that I have to escape, and I have energy that goes disappear every step that i give in the area. I have to give the only one possible solution, the one that uses the least number of steps. If there are at least two sectors with the same number of steps (X1, Y1) and (X2, Y2) then choose the first if X1 < X2 or if X1 = X2 and Y1 < Y2. the position( 1,1) corresponds to the upper left corner. Examples: This is one sector,and i start with 40 of energy and in the position (3,3) 12 11 12 11 3 12 12 12 11 11 12 2 1 13 11 11 12 2 13 2 14 10 11 13 3 2 1 12 10 11 13 13 11 12 13 12 12 11 13 11 13 12 13 12 12 11 11 11 11 13 13 10 10 13 11 12 the best solution to exit the sector is the position (5, 1) the remain energy is 12 and i need 8 steeps to leave the area. for this sector i start with 8 of energy and in the position (3,4). 4 3 3 2 2 3 2 2 5 2 2 2 3 3 2 1 2 2 3 2 2 4 3 3 2 2 4 1 3 1 4 3 2 3 1 2 2 3 3 0 3 4 And for this one there is no way out, cause it looses all the energy.

    Read the article

  • plane bombing problems- help

    - by peiska
    I'm training code problems, and on this one I am having problems to solve it, can you give me some tips how to solve it please. The problem is something like this: Your task is to find the sequence of points on the map that the bomber is expected to travel such that it hits all vital links. A link from A to B is vital when its absence isolates completely A from B. In other words, the only way to go from A to B (or vice versa) is via that link. Notice that if we destroy for example link (d,e), it becomes impossible to go from d to e,m,l or n in any way. A vital link can be hit at any point that lies in its segment (e.g. a hit close to d is as valid as a hit close to e). Of course, only one hit is enough to neutralize a vital link. Moreover, each bomb affects an exact circle of radius R, i.e., every segment that intersects that circle is considered hit. Due to enemy counter-attack, the plane may have to retreat at any moment, so the plane should follow, at each moment, to the closest vital link possible, even if in the end the total distance grows larger. Given all coordinates (the initial position of the plane and the nodes in the map) and the range R, you have to determine the sequence of positions in which the plane has to drop bombs. This sequence should start (takeoff) and finish (landing) at the initial position. Except for the start and finish, all the other positions have to fall exactly in a segment of the map (i.e. it should correspond to a point in a non-hit vital link segment). The coordinate system used will be UTM (Universal Transverse Mercator) northing and easting, which basically corresponds to a Euclidian perspective of the world (X=Easting; Y=Northing). Input Each input file will start with three floating point numbers indicating the X0 and Y0 coordinates of the airport and the range R. The second line contains an integer, N, indicating the number of nodes in the road network graph. Then, the next N (<10000) lines will each contain a pair of floating point numbers indicating the Xi and Yi coordinates (1 No two links will ever cross with each other. Output The program will print the sequence of coordinates (pairs of floating point numbers with exactly one decimal place), each one at a line, in the order that the plane should visit (starting and ending in the airport). Sample input 1 102.3 553.9 0.2 14 342.2 832.5 596.2 638.5 479.7 991.3 720.4 874.8 744.3 1284.1 1294.6 924.2 1467.5 659.6 1802.6 659.6 1686.2 860.7 1548.6 1111.2 1834.4 1054.8 564.4 1442.8 850.1 1460.5 1294.6 1485.1 17 1 2 1 3 2 4 3 4 4 5 4 6 6 7 7 8 8 9 8 10 9 10 10 11 6 11 5 12 5 13 12 13 13 14 Sample output 1 102.3 553.9 720.4 874.8 850.1 1460.5 102.3 553.9

    Read the article

  • how to make a BufferedReader in C

    - by peiska
    I am really new programming in C. How can i do the same in C, maybe in a more simple way then the one a do in Java. Each line of the input have to Integers: X e Y separated by a space. 12 1 12 3 23 4 9 3 InputStreamReader in = new InputStreamReader(System.in); BufferedReader buf = new BufferedReader(in); int n; int k; double sol; String line =""; line=buf.readLine(); while( line != null && !line.equals("")){ String data [] = line.split(" "); n = Integer.parseInt(data[0]); k = Integer.parseInt(data[1]); calculus (n,k); line = buf.readLine(); }

    Read the article

  • What does assert do?

    - by peiska
    What does assert do? for example in the function? private static int charAt(String s, int d) { assert d >= 0 && d <= s.length(); if (d == s.length()) return -1; return s.charAt(d); }

    Read the article

  • Finding number of different paths

    - by peiska
    I have a game that one player X wants to pass a ball to player Y, but he can be playing with more than one player and the others players can pass the ball to Y. I want to know how many different paths can the ball take from X to Y? for example if he is playing with 3 players there are 5 different paths, 4 players 16 paths, if he is playing with 20 players there are 330665665962404000 paths, and 40 players 55447192200369381342665835466328897344361743780 that the ball can take. the number max. of players that he can play with is 500. I was thinking in using Catalan Numbers? do you think is a correct approach to solve this? Can you give me some tips.

    Read the article

  • Reading Inputs in Java - help

    - by peiska
    I am having a problem reading inputs, can anyone help me. Each line of the input have to Integers: X e Y separated by a space. 12 1 12 3 23 4 9 3 I am using this code in java but is not working, its only reading the first line can anyone help me? String []f; String line; Scanner in=new Scanner(System.in); while((line=in.nextLine())!=null){ f=line.split(" "); int X,Y; N=Integer.parseInt(f[0]); K=Integer.parseInt(f[1]); if(X<=40 && Y<=40) metohod(X,Y); linha=in.nextLine(); } }

    Read the article

1