题目大意:
求a^b-b^a的值(a,b<=100)
裸高精度
//Lib #include<cstdio> #include<cstring> #include<cstdlib> #include<cmath> #include<ctime> #include<iostream> #include<algorithm> #include<vector> #include<string> #include<queue> using namespace std; //Macro #define rep(i,a,b) for(int i=a,tt=b;i<=tt;++i) #define rrep(i,a,b) for(int i=a,tt=b;i>=tt;--i) #define erep(i,e,x) for(int i=x;i;i=e[i].next) #define irep(i,x) for(__typedef(x.begin()) i=x.begin();i!=x.end();i++) #define read() (strtol(ipos,&ipos,10)) #define sqr(x) ((x)*(x)) #define pb push_back #define PS system("pause"); typedef long long ll; typedef pair<int,int> pii; const int oo=~0U>>1; const double inf=1e20; const double eps=1e-6; string name="",in=".in",out=".out"; //Var struct Bnum { static const int limit=10000; int num[2008],len;bool flag; int& operator[](int i){return num[i];} Bnum(){memset(num,0,sizeof num);len=0;flag=false;} Bnum(int x){memset(num,0,sizeof num);len=1;num[len]=x;flag=false;} friend bool operator <(Bnum &a,Bnum &b) { if(a.len!=b.len)return a.len<b.len; rrep(i,a.len,1) if(a[i]!=b[i])return a[i]<b[i]; return false; } friend Bnum operator -(Bnum &x,Bnum &y) { Bnum *a=&x,*b=&y; int len=max(a->len,b->len);Bnum c; if(x<y)swap(a,b),c.flag=true; rep(i,1,len) { c[i]+=(*a)[i]-(*b)[i]; if(c[i]<0){c[i+1]--;c[i]+=limit;} } while(!c[len])len--; c.len=len; return c; } friend Bnum operator *(Bnum &a,Bnum &b) { int len=a.len+b.len-1;Bnum c; rep(i,1,a.len)rep(j,1,b.len) { c[i+j-1]+=a[i]*b[j]; c[i+j]+=c[i+j-1]/limit; c[i+j-1]%=limit; } while(c[len+1])len++; c.len=len; return c; } void Print() { if(flag)printf("-"); printf("%d",num[len]); rrep(i,len-1,1)printf("%04d",num[i]); puts(""); } }x,y,t; int a,b; Bnum power(Bnum &a,int b) { if(b==0)return 1; Bnum ret=power(a,b>>1);ret=ret*ret; if(b&1)ret=ret*a; return ret; } void Work() { scanf("%d%d",&a,&b); t=a;x=power(t,b); t=b;y=power(t,a); x=x-y; x.Print(); } int main() { // freopen((name+in).c_str(),"r",stdin); // freopen((name+out).c_str(),"w",stdout); // Init(); Work(); return 0; }
您还没有登录,请您登录后再发表评论
SGU推荐题目分类,适合初次使用sgu的编程爱好者使用!
SGU 390 AC源码,数位统计的难题
SGU 385,我写的程序,一道DP题,跟概率有关
SGU题库整合 Volume (200 - 299) pdf版
sgu oj上的 101-121 的AC代码
辛苦整理所得,分略多,绝对值得,sgu完整题库(530个网页,还有试题难度排序)。lnddszp[at]gmail[dot]com
SGU离线题库(2015-6-8整理),图片可以显示。。
SGU-801综合通讯接入装置使用说明书
SGU 103AC 代码 质量有保证!
SGU 333 集训队AC程序,秒过,CPP
sgu ##这是一个将我的 sol 问题存储到 acm.sgu.ru 的存储库
SGU题库 Volume (100-199) pdf整合版
pku sgu 经典图论题解答, 多种方法解答经典图论题, 附源代码
sgu176 有源汇的上下界 求最小满足的流 poj 2230 递归求欧拉回路 poj 2985 bst模板 poj2723 2-sat验证,二分答案 poj2455 dinic (ek会超时) hdu1689 求最小奇数环 poj2391 isap最快,dinic不减枝会超时 poj2455 ...
ID 标题 交流电 A + B 18881 互质 7697 第3分部 6906 总和 6185 日历 4336 画线 4159 987654321问题 4014 肉饼 3998 几乎素数 3845 a ^ b-b ^ a 3673 骨牌 3621 花小店 3417 ...1884
下载调度程序,用于低带宽环境。 全天扩展下载量
Some solution of problems in SPOJ, all of them use DP technique to attack the problems.
HJVXJVHSKVH JHDK JH DFKSDYFS DVJDSVXCVXCVZXCVZXCV
“#babylonjs-sgu”
SGU-用于搜索github用户的输入表单- 描述 您可以通过输入一些文本来找到github用户。 然后,您将拥有一个用户名和用户图标。 仅显示搜索关键字和用户名之间的数据。 库版本 下一个v10.0.7 Reactv17.0.1 react-dom ...
相关推荐
SGU推荐题目分类,适合初次使用sgu的编程爱好者使用!
SGU 390 AC源码,数位统计的难题
SGU 385,我写的程序,一道DP题,跟概率有关
SGU题库整合 Volume (200 - 299) pdf版
sgu oj上的 101-121 的AC代码
辛苦整理所得,分略多,绝对值得,sgu完整题库(530个网页,还有试题难度排序)。lnddszp[at]gmail[dot]com
SGU离线题库(2015-6-8整理),图片可以显示。。
SGU-801综合通讯接入装置使用说明书
SGU 103AC 代码 质量有保证!
SGU 333 集训队AC程序,秒过,CPP
sgu ##这是一个将我的 sol 问题存储到 acm.sgu.ru 的存储库
SGU题库 Volume (100-199) pdf整合版
pku sgu 经典图论题解答, 多种方法解答经典图论题, 附源代码
sgu176 有源汇的上下界 求最小满足的流 poj 2230 递归求欧拉回路 poj 2985 bst模板 poj2723 2-sat验证,二分答案 poj2455 dinic (ek会超时) hdu1689 求最小奇数环 poj2391 isap最快,dinic不减枝会超时 poj2455 ...
ID 标题 交流电 A + B 18881 互质 7697 第3分部 6906 总和 6185 日历 4336 画线 4159 987654321问题 4014 肉饼 3998 几乎素数 3845 a ^ b-b ^ a 3673 骨牌 3621 花小店 3417 ...1884
下载调度程序,用于低带宽环境。 全天扩展下载量
Some solution of problems in SPOJ, all of them use DP technique to attack the problems.
HJVXJVHSKVH JHDK JH DFKSDYFS DVJDSVXCVXCVZXCVZXCV
“#babylonjs-sgu”
SGU-用于搜索github用户的输入表单- 描述 您可以通过输入一些文本来找到github用户。 然后,您将拥有一个用户名和用户图标。 仅显示搜索关键字和用户名之间的数据。 库版本 下一个v10.0.7 Reactv17.0.1 react-dom ...