别的大佬提供的例子
in: 15
out:
2 3 4 6
144
in: 13
out:
3 4 6
72
in: 8888
out:
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
676032139132129876776568586900593095394354965957048650023128103936001616658412534290367369303253265531945150776452728962114783925860213660797194679459877351878065273318134492100813795594390732800000000000000000000000000000000
in: 888
out:
2 3 4 5 6 7 8 9 10 11 12 13 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
100357579839491421324510186160322254995456000000000
in: 664
out:
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 37
191163237378143681198833049744179200000000
0分代码
#include<bits/stdc++.h>
using namespace std;
#define maxn 10001
long long n,num[maxn],cnt;
long long m[maxn],len=1;
int cheng(long long a){//高精度乘法
for(int j=1;j<=len;j++){
m[j]*=a;
}
for(int j=1;j<=len;j++){
if(m[j]>9){
m[j+1]+=m[j]/10;
m[j]%=10;
}
}
while(m[len+1]>0){
len++;
m[len+1]+=m[len]/10;
m[len]%=10;
}
}
int main(){
cin>>n;
if(n<=4){//特判
cout<<n<<endl<<n;
return 0;
}
for(int i=2;i<=n;i++){
if(n>=i){
cnt++;
num[cnt]=i;
n-=i;
}else break;
}
m[1]=1;
for(int i=cnt;i>=1;i--){
if(n>0){
num[i]++;
n--;
}else break;
}
if(n>0) num[cnt]++;
for(int i=1;i<=cnt;i++){
cout<<num[i]<<' ';
cheng(num[i]);
}
cout<<endl;
for(int i=len;i>=1;i--) cout<<m[i];
return 0;
}