This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* https://www.hackerrank.com/challenges/pairs | |
*/ | |
object Solution { | |
def main(args: Array[String]): Unit = { | |
val (n, k) = readNK(readLine()) | |
val numbers = readNumbers(readLine()) | |
var answer = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @file heap.c | |
* @brief 小根堆. | |
* @author [email protected] | |
* @date 2010-8-1 | |
* @version 0.1 | |
* @note 小根堆的源代码文件 | |
*/ | |
#include "heap.h" | |
#include <stdlib.h> /* for malloc() */ | |
#include <string.h> /* for memcpy() */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @file single_list.c | |
* @brief 单链表 | |
* @author [email protected] | |
* @date 2010-7-30 | |
* @version 0.1 | |
* @note 单链表的源文件 | |
*/ | |
#include <stdlib.h> | |
#include "single_list.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @file stack.c | |
* @brief 栈. | |
* @author [email protected] | |
* @date 2010-7-31 | |
* @version 0.1 | |
* @note 栈的源代码文件 | |
*/ | |
#include "stack.h" | |
#include <stdlib.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#define QUEENS 8 // 皇后的个数,也是棋盘的长和宽 | |
static int total = 0; // 可行解的总数 | |
static int C[QUEENS] = {0}; // C[i]表示第i行皇后所在的列编号 | |
/** | |
* @brief 输出所有可行的棋局,按行打印. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @file queue.c | |
* @brief 队列. | |
* @author [email protected] | |
* @date 2010-7-30 | |
* @version 0.1 | |
* @note 实现了一个循环队列 | |
*/ | |
#include "queue.h" | |
#include <malloc.h> /* for malloc(), free() */ | |
#include <string.h> /* for memcpy() */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @file config.h | |
* @brief 公共头文件 | |
* @author [email protected] | |
* @date 2010-8-3 | |
* @version 0.1 | |
* @note 无 | |
*/ | |
#ifndef _CONFIG_H_ | |
#define _CONFIG_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// POJ 3253 - Fence Repair,http://poj.org/problem?id=3253 | |
#include <iostream> | |
#include <queue> | |
#include <algorithm> | |
#include <functional> | |
using namespace std; | |
typedef long long int64; | |
int main() { | |
int n; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <limits.h> | |
#include <string.h> | |
int N; /** 石头堆的个数. */ | |
int *p; /** 第i堆石头的个数p[i]. */ | |
int **d; /** 状态,d[i][j]表示合并第i堆到第j堆之间的石头的最小得分. */ | |
int *S; /** S[i]表示从第0堆到第i堆的石头总数. */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define MAXN 55555 | |
int N, A[MAXN]; /* 堆数,每堆的石头个数 */ | |
int num, result; /* 数组实际长度,结果 */ | |
void combine(int k) { /* 前提 A[k-1] < A[k+1] */ | |
int i, j; | |
/* 合并 k-1和k */ |
OlderNewer