题意:求[a,b]与n互质的个数
思路:容斥原理的运用,提取n的素因子,先算出不与n互素的个数,容斥原理奇加偶减
#include
#include
#include
#include
#define ll long long
using namespace std;
const int MAXN = 70;
ll prime[MAXN];
ll a,b,n;
ll make(l...
分类:
其他好文 时间:
2014-07-22 23:05:55
阅读次数:
315
以前那个是8皇后问题,用的递归写法,然后这个可以求n皇后放置问题,用的纯粹数学方法……神奇!
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#d...
分类:
其他好文 时间:
2014-07-22 23:04:55
阅读次数:
205
“初始化 定义 赋值” 之间的联系与区别
本来很早之前就想写个blog,说说这三个家伙的区别和联系,三者之间各种联系,很难比较清楚的讲明白,感觉当时好像分析思路还不够“完整”。今天遇到别人抛出来的一个问题。根本的问题是和初始化和赋值有关系,于是留下这个blog。
#include
struct _ANIBMP
{
int FirstNu...
分类:
其他好文 时间:
2014-07-22 23:04:54
阅读次数:
384
经常会在项目中用到 int to string
#include
#include
#include
using namespace std;
int main(void)
{
ostringstream num;
num << 123;
string str = num.str();
cout << str << endl;
return 0;
}...
分类:
编程语言 时间:
2014-07-22 23:04:54
阅读次数:
283
题目链接:uva 10773 - Back to Intermediate Math
题目大意:有一天河,宽d,水流速度v,船速u,问说垂直过河和最快过河的时间差,如果不能过河输出“can't determine”。
解题思路:将u的速度分解成水平方向和竖直方向的两个速度,使水平方向速度恰好为v,船即可垂直过河,速度为竖直方向速度。
#include
#includ...
分类:
其他好文 时间:
2014-07-22 23:04:12
阅读次数:
235
几天被打印信息的去除困扰了,想了想,如果靠一个一个的改动未免太繁琐。因此就仔细的看了下这部分的打印原理。当然下面只是简单的进行了知识罗列不过有需要的朋友可以随便看看。说不准会有些收获呢。
Include/linux/printk.h中有如下定义:
#defineKERN_EMERG
""
/* system is unusable
*/
#defineKERN_ALERT...
分类:
其他好文 时间:
2014-07-22 23:02:35
阅读次数:
250
求矩形和圆是否相交或相切。
#include
#include
#define judge(x,y) x<y||fabs(x-y)<0.00000001
double dis(int x,int y,int a,int b)
{
return (x-a)*(x-a)+(y-b)*(y-b);
}
int main()
{
int T;
scanf(...
分类:
其他好文 时间:
2014-04-30 22:45:38
阅读次数:
365
原型:#include
void * mmap(void *addr, size_t len, int port, int flag, int fildes)参数fd为即将映射到进程空间的文件描述字,一般由open()返回,同时,fd可以指定为-1,此时须指定flags参数中的MAP_ANON,表明进行的是匿名映射(不涉及具体的文件名,避免了文件的创建及打开)
实际上目前的glibc 对mal...
分类:
其他好文 时间:
2014-04-30 22:23:40
阅读次数:
307
链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=36
叼伱个扑街,对呢道题真系无语,,提交5次都过唔到,唔相信既话,伱地可以试下啦。。。
偶噶代码:
#include
#include
#include
#include
...
分类:
其他好文 时间:
2014-04-30 22:16:39
阅读次数:
319
Splay 树的比较基本的序列维护操作, 用getSeg( int l, int r) 获取要操作的区间
若:获取区间[l,r],非空,getSeg(l,r),然后KT指向区间[l,r]
若:获取区间为空,如当要在l位置插入一个值时,则getSeg(l,l-2),然后可在KT赋值新节点
D. Cup Trick
#include
#include
#include
#include...
分类:
其他好文 时间:
2014-04-30 22:14:40
阅读次数:
326