易截截图软件、单文件、免安装、纯绿色、仅160KB

更高效率的A^B mod C bird

#include <stdio.h>
#define LL unsigned long long int

inline LL mod(LL a,LL b)
{
while (a>=b)
a-=b;
return a;
}
//a*b mod c
inline LL MulAndMod(LL a, LL shl_b,LL c)
{
LL val,pre;
pre = mod(a,c);
val = 0;
while (shl_b)
{
if (shl_b&0x1)
val = mod(val + pre,c);
shl_b>>=1;
pre = mod(pre<<1,c);
}
return val;
}

inline LL A_BModC(LL a,LL shl_b,LL c)
{

LL val,pre;
if (shl_b&0x1) //根据2相应二进制位的值判断是否加A*2^n;\\因为有对b进行右移运算,所以每次只需判断最末位的结果就可以。
val = mod(a,c);
else
val = 1;
shl_b >>= 1; //计算 A*2^n的值。
pre = MulAndMod(a,a,c);
while (shl_b)
{
if (shl_b&0x1)
val = MulAndMod(val,pre,c);
shl_b>>=1;
pre = MulAndMod(pre,pre,c);
}
return val;
}

int main()
{
LL a,b,c;
while (scanf("%llu%llu%llu", &a,&b,&c)!=EOF)
printf("%llu\n", A_BModC(a,b,c));
return 0;
}


相关文档:

我的c学习之路二 hello world


<!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"\@宋体" ......

UVa 327 Evaluating Simple C Expressions

/*
coder: ACboy
date: 2010-3-14
result: 1A
description: UVa 327 Evaluating Simple C Expressions
*/
#include <iostream>
#include <algorithm>
using namespace std;
struct Node {
char name;
int value;
int lastValue;
int pos;
};
int cmp(const Node & a, const Node &a ......

B/S+C/B+webservice+ALC

今天突然想到B/S结构里,webform是无法取得客户端的MAC地址和硬件信息的,就突发奇想,用C/S结构,但是因为C/S结构的很多的东西不能动态,就考虑到了C/B结构
最后决定用webservice+ALC+C/B结构 ,搭建我的OA系统
努力ing ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号