Introduction

This is my blog of programming, I take notes and leave codes of computer science problems I solved here. Be my guest to comment :)

Wednesday, January 30, 2013

uva 10278 - Fire Station

  1 /*
  2  Problem link
  3  Type: Graph - Single source shortest path
  4  Algorithm:
  5      First run Floyd (or Dijkstra to every vertex n), for each vertex
  6      find the distance to the nearest station, get the max of those nearest station.
  7  
  8      For the vertex which is not a station, place a station there and run Dijkstra
  9      for that vertex. Recalculate the distance to the nearest station for each vertex
 10      by the distance array from the Dijkstra and update the for the "better max".
 11  */

uva 100 - The 3n + 1 problem

/*
Problem link
Type: Adhoc
Algorithm: Straight forward 
*/ 

Wednesday, January 23, 2013

Tuesday, January 22, 2013

Thursday, January 17, 2013

Wednesday, January 2, 2013

uva 821 - Page Hopping


 1 /*
 2  Problem link
 3  Type: Graph
 4  Algorithm:
 5      Use floyd to find all pair shortest path, sum them up, divide to the number of pair
 6      I use the map to mark for the vertex in the input.
 7  */

Tuesday, January 1, 2013

uva 423 - MPI Maelstrom


 1 /*
 2  Problem link
 3  Type: Graph
 4  Algorithm:
 5      Use Floyd or Dijkstra to find the shortest path from 1 to n-1 others nodes.
 6      Find the max of the shortest path from 1 to n-1 others nodes.
 7  */