题目链接:hdu 4983 Goffi and GCD
题目大意:求有多少对元组满足题目中的公式。
解题思路:
n = 1或者k=2时:答案为1k > 2时:答案为0(n≠1)k = 1时:需要计算,枚举n的因子,令因子k=gcd(n?a,n,
那么另一边的gcd(n?b,n)=nk才能满足相乘等n,满足k=gcd(n?a,n)的a的个数即为?(n/s),欧拉有o(n ̄ ̄√的...
分类:
其他好文 时间:
2014-08-25 01:13:33
阅读次数:
315
Now a days a very common problem is:“The coordinate of two points in Cartesian coordinate system is (200, 300) and(4000, 5000). If these two points are connected we get a line segment. How manylattice...
分类:
其他好文 时间:
2014-08-24 23:54:33
阅读次数:
406
HDU 4983 Goffi and GCD
思路:数论题,如果k为2和n为1,那么只可能1种,其他的k > 2就是0种,那么其实只要考虑k = 1的情况了,k = 1的时候,枚举n的因子,然后等于求该因子满足的个数,那么gcd(x, n) = 该因子的个数为phi(n / 该因子),然后再利用乘法原理计算即可
代码:
#include
#include
#include
...
分类:
其他好文 时间:
2014-08-24 23:53:53
阅读次数:
311
这个算法是用来求满足下列条件的整数x和y: d = gcd(a,b) = ax+by (d为a,b的最大公约数)算法导论上给出的伪代码: EXTENDED_EUCLID(a,b) 1 if b==0 2 return (a,1,...
分类:
其他好文 时间:
2014-08-24 23:40:53
阅读次数:
339
SPOJ Problem Set (classical)7001. Visible Lattice PointsProblem code: VLATTICEConsider a N*N*N lattice. One corner is at (0,0,0) and the opposite one ...
分类:
其他好文 时间:
2014-08-24 20:42:43
阅读次数:
146
一、延时执行1、iOS常见的延时执行有2种方式 (1)调用NSObject的方法[self performSelector:@selector(run) withObject:nil afterDelay:2.0];// 2秒后再调用self的run方法 (2)使用GCD函数dispatch_a.....
分类:
移动开发 时间:
2014-08-24 12:52:32
阅读次数:
241
dfs判断欧拉图,红名选手的代码就是炫酷。
首先统计所有点的度数总和,而后对于这张图的特殊性——每个点最多只会有四条边,来标记当前边是否走过了。
若在一次DFS中,能遍历所有的节点则输出所有边长的gcd的大于1的约数集。
真心学习了。#include
#include
#include
#include
#include
#include
#include
#include
...
分类:
其他好文 时间:
2014-08-23 21:44:01
阅读次数:
228
一、基本概念1、什么是GCD全称是Grand Central Dispatch,可译为“牛逼的中枢调度器”纯C语言,提供了非常多强大的函数2、GCD的优势GCD是苹果公司为多核的并行运算提出的解决方案GCD会自动利用更多的CPU内核(比如双核、四核)GCD会自动管理线程的生命周期(创建线程、调度任务...
分类:
移动开发 时间:
2014-08-23 20:22:01
阅读次数:
261
String Matching
Time Limit: 1000MS
Memory Limit: 10000K
Total Submissions: 3717
Accepted: 1913
Description
It's easy to tell if two words are identical - just check t...
分类:
其他好文 时间:
2014-08-23 08:50:50
阅读次数:
219
欧几里得算法(又称辗转相除法)定理:gcd(a,b) = gcd(a,a mod b)证明:对于任何正整数a,b。如果a>b,都有a=k*b+r 即r=a-k*b => r=a mod b. 假设d为a,b的公约数,则a=a1*d,b=b1*d。 而r=a1*d-k*b1*d=(a1-k*b1)*d...
分类:
其他好文 时间:
2014-08-22 00:09:15
阅读次数:
287