Tags » Categories

TV Pick of the Day - Thursday 29 September

Tim Burton fan Zoe Butcher has a Hollow pick for tonight’s viewing… 155 more words

TV

Off shoulder tops

The off shoulder top is definitely a trend I’m loving. Although, it is not for formal gatherings,it is perfect for social(informal) gatherings.But don’t overdo it, yes! 81 more words

Categories

KMP

#include <stdio.h>
#include <string.h>
#define MAXL 1000000
char T, P;
int pi;
void fi(){
	int i, j, m = strlen(P);
	pi[0] = -1; i = 0; j = -1;
	while (i < m){
		if (j == -1 || P[i] == P[j]){
			i++, j++;
			pi[i] = j;
		}
		else j = pi[j];
	}
}
void match(){
	int i, j, n = strlen(T), m = strlen(P); i = j = 0;
	while (i < n){
		if (j == -1 || T[i] == P[j]) i++, j++;
		else j = pi[j];
		if (j == m){
			printf("Match : %d to %d\n", i - m + 1, i);
			j = pi[j];
		}
	}
}
int main(){
	gets(T); gets(P);
	fi(); match();
	return 0;
}
Categories~

Bellman - Ford

/*
벨만포드 알고리즘 O(VE) - 음수간선처리 최단경로
*/
#include <stdio.h>
#pragma warning(disable:4996)
#define MAXVERTEX 10000
#define MAXEDGE 10000
struct graph{
	int from, dest;
	int weight;
}edge;
int Num_Vertex, Num_Edge;
int dist;
void Bellman_Ford(int src){
	for (int i = 1; i <= Num_Vertex; i++){
		dist[i] = 0x7fffffff;
	} dist = 0;
	for (int i = 1; i <= Num_Vertex - 1; i++){ // |V| - 1 만큼 refresh
		for (int j = 1; j <= Num_Edge; j++){
			int u = edge[j].from;
			int v = edge[j].dest;
			int w = edge[j].weight;
			if (dist[u] != 0x7fffffff && dist[u] + w < dist[v]){
				dist[v] = dist[u] + w;
			}
		}
	}
	// Negative 싸이클 chk!! 124 more words
Categories~