Problem Description
Agrael likes play a simple game with his friend Animal during the classes. In this Game there are n piles of stones numbered from 1 to n, the 1st pile has M1 stones, the 2nd pile has M2 stones, ... and the n-th pile contain Mn stones. A...
分类:
其他好文 时间:
2015-03-30 16:33:51
阅读次数:
141
题目大意:
我们来递归定义一个友好数:
(1)整数1、2是友好数
(2)如果a和b是友好数,那么a*b + a + b也是友好数
(3)只有用(1)和(2)定义的数是友好数。
现在给你一个数n(0 <= n <= 30),判断n是否是友好数
思路:
挺有意思的一道简单数学题。设n是一个友好数,那么n就可以分解为:
n = a*b + a + b = (a+1)*(b+1) - 1,即n+1 = (a+1)*(b+1)由递归定义,这里的a和b也必须是友好数。
a = a1*b1 + a1 + b1 = (a...
分类:
其他好文 时间:
2015-03-30 13:25:32
阅读次数:
121
AvlTree.h
#include
#include
#include
using namespace std;
template
class AvlTree;
template
class AvlNode{
friend class AvlTree ;
T data;
int height;
AvlNode *left;
AvlNode *right;
Avl...
分类:
其他好文 时间:
2015-03-30 09:34:31
阅读次数:
112
OneKdTree.h
#include
#include
#include
using namespace std;
class AvlTree;
class AvlNode{
friend class AvlTree;
int data;
int height;
AvlNode *left;
AvlNode *right;
AvlNode(int _data) :da...
分类:
其他好文 时间:
2015-03-30 09:25:54
阅读次数:
219
1936. Knight Moves
Constraints
Time Limit: 1 secs, Memory Limit: 32 MB
Description
A friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the s...
分类:
其他好文 时间:
2015-03-30 09:20:21
阅读次数:
121
这里介绍一个基础的搜索引擎技术
假如有两段文字
1,books and friends should be few but good
2,A good book is a good friend
假如我们忽略掉大小写和复数,可以整理出一张单词表,显示哪个单词再哪段文字,
英文单词
文章编号
a
2
and
1
be
1
bo...
分类:
其他好文 时间:
2015-03-29 22:17:03
阅读次数:
450
6.若不想使用编译器默认生成的函数,就该明确拒绝 1.有的时候不希望对象被复制和赋值,那么就把复制构造函数与赋值运算符放在private:中,但是这两个函数是否需要实现呢?假设实现了,那么你的类成员方法和friend函数(类)仍然可以使用这些方法,最好的方法是在private:中声明儿不定义他们,这...
分类:
其他好文 时间:
2015-03-29 19:24:26
阅读次数:
130
烂大街的IOI2014题解
IOI2014 Rail(单调栈)
IOI2014 Wall(区间修改线段树)
IOI2014 Game(构造)
IOI2014 Gondola(模拟+快速幂)
IOI2014 Friend(树形DP)
IOI2014 Holiday(函数式线段树+决策单调性分治)...
分类:
其他好文 时间:
2015-03-29 16:35:38
阅读次数:
452
UVA - 439
Knight Moves
Time Limit: 3000MS
Memory Limit: Unknown
64bit IO Format: %lld & %llu
Submit Status
Description
A friend of you is doing research on t...
分类:
其他好文 时间:
2015-03-28 08:51:36
阅读次数:
146
//智能指针类
//----------------------------------------
//1.基数据放在使用计数类中
//实际类指向->使用计数类->基数据
//使用计数类
class U_ptr{
friend class Hasptr;//友元类
int *ip;//这个就是要保护的基数据
size_t use;
U_ptr(int *p):ip(p),use(1){...
分类:
其他好文 时间:
2015-03-18 20:39:07
阅读次数:
121