发现其实有关gcd的题目还是挺多的,这里根据做题顺序写出8题。[bzoj2818: Gcd] gcd(x,y)=质数, 1#include const int MAXN = 10000001;int n, primes;long long prime[MAXN], phi[MAXN];bool co...
分类:
其他好文 时间:
2014-06-25 22:12:36
阅读次数:
317
Divide two integers without using multiplication, division and mod operator.
思路:1.先将被除数和除数转化为long的非负数,注意一定要为long,因为Integer.MIN_VALUE的绝对值超出了Integer的范围。
2.常理:任何正整数num都可以表示为num=2^a+2^b+2^c+.....
分类:
其他好文 时间:
2014-06-25 19:46:17
阅读次数:
246
public static long gcd(long m, long n) {
}...
分类:
其他好文 时间:
2014-06-24 23:58:40
阅读次数:
406
题目链接:uva 10843 - Anne's game
题目大意:给出n,问说有n个节点构成的标号树有多少种。
解题思路:cayley定理的躶题。
#include
#include
typedef long long ll;
const ll MOD = 2000000011;
ll Pow (ll x, ll n) {
if (n 0)
ret...
分类:
其他好文 时间:
2014-06-24 23:46:31
阅读次数:
239
struct student{ long num; float score; struct student *next;};注意:只是定义了一个struct student类型,并未实际分配存储空间。只有定义了变量才分配内存单元。#includeusing namespace std;int mai...
分类:
编程语言 时间:
2014-06-24 22:24:45
阅读次数:
318
hdu 3037 Saving Beans
题目大意:n个数,和不大于m的情况,结果模掉p,p保证为素数。
解题思路:隔板法,C(nn+m)多选的一块保证了n个数的和小于等于m。但是n,m很大,所以用到Lucas定理。
#include
#include
#include
using namespace std;
typedef long long ll;
ll n, m,...
分类:
其他好文 时间:
2014-06-24 21:07:40
阅读次数:
220
http://www.2cto.com/kf/201402/281501.html123456NSString *str = @"0xff055008";//先以16为参数告诉strtoul字符串参数表示16进制数字,然后使用0x%X转为数字类型unsigned long red = strtoul...
分类:
移动开发 时间:
2014-06-24 19:43:58
阅读次数:
248
C语言中宏的使用(#,##,do…while(0)宏)
1.预定义宏的使用__FILE__,__FUNCTION__,__LINE__。
#include
void fun(void)
{
char v1;
short v2;
int v3;
long v4;
printf("v1: %x\n",&v1);
printf("v2: %x\n",&v2);
print...
分类:
编程语言 时间:
2014-06-24 15:29:13
阅读次数:
214
1. 按两下返回键退出 代码如下: private long exitTime = 0; @Overridepublic boolean onKeyDown(int keyCode, KeyEvent event) { ExitApp(); return false;}public void Exi...
分类:
其他好文 时间:
2014-06-24 13:43:40
阅读次数:
180
生产者#include#include#includeusing namespace std; int main(void) { ofstream out; const char ch = '*'; long long k = 0; DWORD64 time = GetTickCount64(); ...
分类:
其他好文 时间:
2014-06-24 11:29:19
阅读次数:
354