Skip to content

Instantly share code, notes, and snippets.

View Abreto's full-sized avatar
🔋
Charging

Abreto Abreto

🔋
Charging
View GitHub Profile
@Abreto
Abreto / 1040.c
Last active December 26, 2015 14:29
Wikioi - 1040. Counting.
/* Wikioi - Problem 1040 count the number of words; . by Abreto. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_CHARS (201)
#define MAX_WORDS (7)
int k = 0, s = 0;
char str[MAX_CHARS] = {0};
int nstrchrs = 0;
@Abreto
Abreto / 1039.c
Created October 22, 2013 14:29
Wikioi - Problem 1039.
/* Wikioi - Proeblem 1039 . by Abreto. */
#include <stdio.h>
#define MAXN 200
#define MAXK 6
int f[MAXN+1][MAXN+1][MAXK+1] = {{{0}}};
int
dp(int i, int n, int k)
{
@Abreto
Abreto / 1017.c
Created October 20, 2013 15:02
Wikioi - 1017 乘积最大
/* Wikioi - Problem 1017 Maxmul. by Abreto. */
#include <stdio.h>
#define MAXL (50)
#define MAXK (10)
typedef long long int lint;
int N = 0, K = 0;
char a[MAXL] = {0};
lint g[MAXL][MAXL] = {{0}};
@Abreto
Abreto / 1200.c
Created October 20, 2013 05:04
Wikioi 1200 - 同余方程
/* Wikioi - Problem 1200 Equation. by Abreto. */
#include <stdio.h>
#define ABS(x) ( ((x)>0) ? (x) : (-(x)) )
int exgcd(int m, int n, int * x)
{
int q = 0;
int x0 = 1, x1 = 0;
int t = 0;
@Abreto
Abreto / 1169.c
Created October 20, 2013 04:40
Wikioi 1169 - 传递纸条.
/* Wikioi - Problem 1169 Passing notes. */
#include <stdio.h>
#define MAX(a,b) ( ((a)>(b))?(a):(b) )
#define MAX4(a,b,c,d) (MAX(MAX((a),(b)),MAX((c),(d))))
#define MAXSIZE 52
int m = 0, n = 0;
int mat[MAXSIZE][MAXSIZE] = {{0}};
int f[MAXSIZE][MAXSIZE][MAXSIZE] = {{{0}}};
@Abreto
Abreto / 1010.c
Created October 19, 2013 15:52
Wikioi 1010
/* Wikioi - Problem 1010 Dabing crossing the river. */
#include <stdio.h>
#define CONTROLEDBYHORSE(i, j) ( (X == (i) && Y == (j)) || (X-1 == (i) && Y-2 == (j)) || (X-2 == (i) && Y-1 == (j)) || (X-2 == (i) && Y+1 == (j)) || (X-1 == (i) && Y+2 == (j)) || (X+1 == (i) && Y-2 == (j)) || (X+2 == (i) && Y-1 == (j)) || (X+2 == (i) && Y+1 == (j)) || (X+1 == (i) && Y+2 == (j)) )
#define OUTOFBOARD(i, j) ( ((i) > n) || ((j) > m) )
typedef long long int lint;
int n = 0, m = 0;
int X = 0, Y = 0;
@Abreto
Abreto / p1048.c
Created October 14, 2013 15:33
Wikioi 1048 石子归并
/* Wikioi - Problem 1048 */
#include <stdio.h>
#include <limits.h>
int n = 0;
int M[101][101] = {{0}};
int w[101] = {0};
int S[101] = {0};
int dp(int left, int right)
@Abreto
Abreto / p1154.c
Created October 14, 2013 15:32
Wikioi 1154 能量项链
/* Wikioi - Problem 1154. by Abreto. */
#include <stdio.h>
#define POSITION(i) ( (i) % N )
int N = 0;
int mark[201] = {0};
int M[201][201] = {{0}};
int
dp(int h, int t)
@Abreto
Abreto / memory.c
Last active January 7, 2016 07:11
模拟内存分配、释放管理
/* simulate memory management. Abreto 20130806. */
#ifndef NULL
#define NULL ( 0 )
#endif
/* Memory size: 64KiB. */
#define _MEMORY_SIZE ( 64 * 1024 )
/* Maxium number of blocks. */
#define _BLOCK_NUM ( _MEMORY_SIZE/4 )
@Abreto
Abreto / gist:5450958
Created April 24, 2013 09:34
PC110202/UVa10315
/* PC 110201 - Jolly Jumper */
#include <stdio.h>
#include <string.h>
#define ABS(x) ( ((x)>0) ? (x) : (-(x)) )
char bits[3002] = {0};
int main(void)
{
int n = 0;