2 条题解
-
1sunheming LV 4 @ 2020-06-24 07:45:27
#include<iostream> #include<string> using namespace std; string str[100]={"1","5","16","45","121","320","841","2205","5776","15125","39601","103680","271441","710645","1860496","4870845","12752041","33385280","87403801","228826125","599074576","1568397605","4106118241","10749957120","28143753121","73681302245","192900153616","505019158605","1322157322201","3461452808000","9062201101801","23725150497405","62113250390416","162614600673845","425730551631121","1114577054219520","2918000611027441","7639424778862805","20000273725560976","52361396397820125","137083915467899401","358890350005878080","939587134549734841","2459871053643326445","6440026026380244496","16860207025497407045","44140595050111976641","115561578124838522880","302544139324403592001","792070839848372253125","2073668380220713167376","5428934300813767249005","14213134522220588579641","37210469265847998489920","97418273275323406890121","255044350560122222180445","667714778405043259651216","1748099984655007556773205","4576585175559979410668401","11981655542024930675232000","31368381450514812615027601","82123488809519507169850805","215002084978043708894524816","562882766124611619513723645","1473646213395791149646646121","3858055874062761829426214720","10100521408792494338631998041","26443508352314721186469779405","69230003648151669220777340176","181246502592140286475862241125","474509504128269190206809383201","1242282009792667284144565908480","3252336525249732662226888342241","8514727565956530702536099118245","22291846172619859445381409012496","58360810951903047633608127919245","152790586683089283455442974745241","400010949097364802732720796316480","1047242260609005124742719414204201","2741715832729650571495437446296125","7177905237579946589743592924684176","18791999880010189197735341327756405","49198094402450621003462431058585041","128802283327341673812651951847998720","337208755579574400434493424485411121","882823983411381527490828321608234645","2311263194654570182037991540339292816","6050965600552329018623146299409643805","15841633607002416873831447357889638601","41473935220454921602871195774259272000","108580172054362347934782139964888177401","284266580942632122201475224120405260205","744219570773534018669643532396327603216","1948392131377969933807455373068577549445","5100956823360375782752722586809405045121","13354478338703157414450712387359637585920","34962478192749096460599414575269507712641","91532956239544131967347531338448885552005","239636390525883299441443179440077148943376","627376215338105766356982006981782561278125"}; int main(){ int n; cin>>n; cout<<str[n-1]; return 0; }
#include<iostream> #include<cstdio> using namespace std; struct data{ int a[101],len; }; int n; data mul(data a,int k) { for(int i=1;i<=a.len;i++) a.a[i]*=k; for(int i=1;i<=a.len;i++) { a.a[i+1]+=a.a[i]/10; a.a[i]%=10; } if(a.a[a.len+1]!=0)a.len++; return a; } data sub(data a,data b) { a.a[1]+=2; int j=1; while(a.a[j]>=10){a.a[j]%=10;a.a[j+1]++;j++;} for(int i=1;i<=a.len;i++) { a.a[i]-=b.a[i]; if(a.a[i]<0){a.a[i]+=10;a.a[i+1]--;} } while(a.a[a.len]==0)a.len--; return a; } int main() { data f[101];f[1].a[1]=1;f[2].a[1]=5; f[1].len=f[2].len=1; scanf("%d",&n); for(int i=3;i<=n;i++) f[i]=sub(mul(f[i-1],3),f[i-2]); for(int i=f[n].len;i>0;i--) printf("%d",f[n].a[i]); return 0; }
#include<iostream> #include<cstdio> #include<cstring> using namespace std; const int N = 110; const int L = 1010; int n; struct NUM{ int len, s[L]; NUM operator = (int x){ memset(s, 0, sizeof(s)); len = 1; s[1] = x; return *this; } NUM operator + (NUM x){ NUM y; memset(y.s, 0, sizeof(y.s)); y.len = max(len, x.len); for (int i = 1; i <= y.len; i++){ y.s[i] += s[i]+x.s[i]; y.s[i+1] += y.s[i]/10; y.s[i] %= 10; } while (y.s[y.len+1] > 0){ y.len++; y.s[y.len+1] += y.s[y.len]/10; y.s[y.len] %= 10; } return y; } void print(){ for (int i = len; i >= 1; i--) putchar(s[i]+'0'); putchar('\n'); } }f[N], g[N], delf[N], delg[N]; int main() { scanf("%d", &n); f[1] = delf[1] = 1; g[1] = delg[1] = 0; for (int i = 2; i <= n; i++){ delf[i] = delf[i-1]+f[i-1]; f[i] = f[i-1]+delf[i]; delg[i] = delg[i-1]+delf[i-1]+delf[i-1]; g[i] = g[i-1]+delg[i]; } (f[n]+g[n]).print(); return 0; }
-
-12017-05-14 13:44:06@
n<=10,打表啊
- 1
信息
- 难度
- 7
- 分类
- (无)
- 标签
- 递交数
- 235
- 已通过
- 53
- 通过率
- 23%
- 被复制
- 1
- 上传者