elong123 @ 2023-05-10 17:31:14
000
by elong123 @ 2023-05-10 17:32:25
@elong123 看看我的函数
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char* multiply(char *num1,char * num2){
int a[2002]={0},b[2002]={0},c[2002]={0};
int la = strlen(num1);
int lb = strlen(num2);
int lc = la + lb;
//1.倒序存入
for(int i = 0;i < la;i++){
a[la - i - 1] = num1[i] - '0';
}
for(int j = 0; j <lb ;j++){
b[lb - j - 1] = num2[j] -'0';
}
// //2.乘法的进制存储
// for(int i = 0; i<la;i++){
// for(int j = 0 ; j < lb ; j++){
// c[i + j] += a[i] * b[j];
// c[i + j + 1] += c[i + j] /10 ;
// c[i + j] %= 10;
// }
// }
//2.1加法的进制转化
for(int i = 0; i< lc; i++){
c[i] += a[i] + b[i];
c[i + 1] = c[i] /10;
c[i] %= 10;
}
//3.排除特例
while(c[lc] == 0 && lc>0) lc--;
//4.定义一个动态字符串存储
char *re = (char *)malloc(sizeof(char)*(lc+2));
//5.存储
for(int i = lc ;i >=0 ; i--){
re[lc - i] = c[i] +'0';//将数组转为字符串+‘0’;
}
re[lc + 1] = 0;
return re;
}
int main(){
int n;
char num1[2002],num2[2002];
scanf("%d",&n);
fr
// char num1[20002],num2[20002];
// scanf("%s \n %s",num1,num2);
// char* num = multiply(num1,num2);
// printf("%s",num);
// free(num);
// return 0;
}
by wwb11 @ 2023-05-16 20:19:27
有个阴间的
#include<iostream>
using namespace std;
int main()
{
string q[60]={"0","1","3","9","33","153","873","5913","46233","409113","4037913","43954713","522956313","6749977113","93928268313","1401602636313","22324392524313","378011820620313","6780385526348313","128425485935180313","2561327494111820313","53652269665821260313","1177652997443428940313","27029669736328405580313","647478071469567844940313","16158688114800553828940313","419450149241406189412940313","11308319599659758350180940313","316196664211373618851684940313","9157958657951075573395300940313","274410818470142134209703780940313","8497249472648064951935266660940313","271628086406341595119153278820940313","8954945705218228090637347680100940313","304187744744822368938255957323620940313","10637335711130967298604907294846820940313","382630662501032184766604355445682020940313","14146383753727377231082583937026584420940313","537169001220328488991089808037100875620940313","20935051082417771847631371547939998232420940313","836850334330315506193242641144055892504420940313","34289376947494122614363304694584807557656420940313","1439295494700374021157505910939096377494040420940313","61854558558074209658512637979453093884758552420940313","2720126133346522977702138448994068984204397080420940313","122342346998826717539665299944651784048588130840420940313","5624964506810915667389970728744906677010239883800420940313","264248206017979096310354325882356886646207872272920420940313","12678163798554051767172643373255731925167694226950680420940313","620960027832821612639424806694551108812720525606160920420940313","31035053229546199656252032972759319953190362094566672920420940313"};
int n;
cin>>n;
cout<<q[n];
return 0;
}
不推荐使用(但有用)
by wwb11 @ 2023-05-16 20:20:08
网上搜的表
by Sqj147 @ 2023-06-10 17:29:15
// 1 * 2 * 3 * ... * n
a[0] = b[0] = 1;
for (int i = 2; i <= n; i ++) {
for (j = 0; j < 100; j ++)
b[j] *= i;// 1 * 2 * ... * i
// 高精度处理
for (j = 0; j < 100; j ++)
a[j] += b[j];// 求和
// 高精度处理
}
// 去除前导0
for (i = 100; i >= 0 && a[i] == 0; i --);
// 倒序输出
for (j = i; j >= 0; j --) cout << a[j];