SGU112

本文探讨了如何使用高精度运算解决特定数学问题,并通过裸题的方式展示了解题过程和技巧,适合对算法和数据结构有兴趣的学习者深入研究。
部署运行你感兴趣的模型镜像

题目大意:

求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; }

您可能感兴趣的与本文相关的镜像

HunyuanVideo-Foley

HunyuanVideo-Foley

语音合成

HunyuanVideo-Foley是由腾讯混元2025年8月28日宣布开源端到端视频音效生成模型,用户只需输入视频和文字,就能为视频匹配电影级音效

根据我提供的信息,优化程序 待写入的topic是三个分区; 生产者线程调整为4; {"log_type":"auth","cnmaster":"764991563","last_domain":"tlbbgl-activity.changyou.com","phone":"0FDD7A79D10EE13430AFDF","media_type":"{\"base_url\":\"https://tlbbgl.changyou.com/\"}","ip":"182.135.97.61","product_id":"90","time":"2025-07-09 15:54:42","cn":"qstl0709@changyou.com","type":"oldAccount","current_domain":"auth.changyou.com","mac_new":"0"} {"log_type":"auth","cnmaster":"zjhy107@changyou.com","last_domain":"tlbbglact.changyou.com","phone":"0FD07A73D003E43236A7DE","media_type":"{\"rcc_id\":\"788920c8-61cb-4d27-a228-5c1d31fe5862\",\"type\":\"xdlb3\",\"sid\":\"52746\",\"sign\":\"A8AACB481CA753C80215182224ECF006\",\"base_url\":\"https://tlbbglact.changyou.com/tlbbgl/rlr/20250507/m/index17.shtml\"}","ip":"183.199.230.1","product_id":"90","time":"2025-07-09 15:54:46","cn":"zjhy107@changyou.com","type":"oldAccount","current_domain":"auth.changyou.com","mac_new":"0"} {"log_type":"auth","cnmaster":"602132693","last_domain":"tlbbgl-activity.changyou.com","phone":"0FDD7B79D00AE13631A2DD","media_type":"{\"base_url\":\"https://tlbbgl.changyou.com/m/index.shtml\",\"rcc_id\":\"01b8800c-74e7-4303-90b8-98e414783c66\",\"type\":\"gfgzh1\"}","ip":"218.56.20.246","product_id":"90","time":"2025-07-09 15:54:49","cn":"237176761@qq.com","type":"oldAccount","current_domain":"auth.changyou.com","mac_new":"0"} {"log_type":"auth","cnmaster":"764991582","last_domain":"tlbbglact.changyou.com","phone":"0FDC7672D00FE73736A6DD","media_type":"{\"rcc_id\":\"f9b1f1cf-bc85-40cb-b4e4-5fe2997ff177\",\"type\":\"xdlb14\",\"sid\":\"27597\",\"sign\":\"D76F6FA0C3CFCB6598E7EC9E5B71EA8A\",\"base_url\":\"https://tlbbglact.changyou.com/tlbbgl/rlr/20250507/m/index37.shtml\"}","ip":"117.136.8.228","product_id":"90","time":"2025-07-09 15:54:52","cn":"0FDC7672D00FE73736A6DD","type":"newAccount","current_domain":"auth.changyou.com","mac_new":"0"} {"log_type":"auth","cnmaster":"574596646","last_domain":"tlbbgl-activity.changyou.com","phone":"0FD27471D50EE03432A3D9","media_type":"{\"base_url\":\"https://tlbbgl.changyou.com/load/20250523/index.shtml\",\"rcc_id\":\"949acafa-1833-44f3-b899-03f250dd8f78\",\"media\":\"bd\",\"type\":\"bdsemob1\",\"bd_vid\":\"8536153497538321445\"}","ip":"58.240.95.36","product_id":"90","time":"2025-07-09 15:54:55","cn":"0FD27471D50EE03432A3D9","type":"oldAccount","current_domain":"auth.changyou.com","mac_new":"0"} {"log_type":"auth","cnmaster":"715406543","last_domain":"tlbbglact.changyou.com","phone":"0FD37471D70DE63736A3DE","media_type":"{\"rcc_id\":\"f9b1f1cf-bc85-40cb-b4e4-5fe2997ff177\",\"type\":\"xdlb14\",\"base_url\":\"https://tlbbglact.changyou.com/tlbbgl/rlr/20250507/m/index03.shtml\"}","ip":"1.197.240.150","product_id":"90","time":"2025-07-09 15:54:56","cn":"bs0410@changyou.com","type":"oldAccount","current_domain":"auth.changyou.com","mac_new":"0"} {"log_type":"auth","cnmaster":"731641905","last_domain":"tlbbgl-activity.changyou.com","phone":"0FDD7671D70CE1313BAFD3","media_type":"{\"base_url\":\"https://tlbbgl.changyou.com/load/20250701/m/index.shtml\",\"kscallback\":\"KvI4N-snDnO5j90vY8WBWi_MNuOQ-XKA_VvjczWc1dlkR-a74F8a2tIC54j2hp8Ch8qNSLaziB60yCCOVEDqfW32CyxNYQ1_ZSJM4L6dtu5l3Hxn0JNf_r9UdFAkpygreSicn-aXuiytn01k8sgU8GKrhYT6rdt9j8YWDFnWARzpEieYEJrRjaViX6xajd1B7gch_dog2Cj9xoICAdyfxTuK20AP6d2BWAbO3Iu7kqFbGfGHR-yPk-gIcwMOERFp\",\"rcc_id\":\"d6e4cad6-357a-418d-94cb-2105288bd6e4\",\"media\":\"ks\",\"type\":\"tfby3\"}","ip":"112.65.27.242","product_id":"90","time":"2025-07-09 15:54:57","cn":"0FDD7671D70CE1313BAFD3","type":"oldAccount","current_domain":"auth.changyou.com","mac_new":"0"} {"log_type":"auth","cnmaster":"758218289","last_domain":"tlbbgl-activity.changyou.com","phone":"0FDD7170D702EB3937A7D9","media_type":"{\"rcc_id\":\"1c817f78-f113-499c-be6f-de523b199a2b\",\"wx_aid\":\"43651481675\",\"base_url\":\"https://tlbbgl.changyou.com/load/20250523/m/index.shtml\",\"wx_traceid\":\"wx0b2fzf6bw6kg5o01\",\"media\":\"gdt\",\"type\":\"gdtob2\",\"tid\":\"43651555625\",\"gdt_vid\":\"wx0b2fzf6bw6kg5o01\"}","ip":"183.224.110.1","product_id":"90","time":"2025-07-09 15:54:58","cn":"0FDD7170D702EB3937A7D9","type":"oldAccount","current_domain":"auth.changyou.com","mac_new":"0"} 这几种格式的json随机发送,内容做替换
07-10
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值