Problem Description

度熊面前有一个全是由1构成的字符串,被称为全1序列。你可以合并任意相邻的两个1,从而形成一个新的序列。对于给定的一个全1序列,请计算根据以上方法,可以构成多少种不同的序列。

Input

这里包括多组测试数据,每组测试数据包含一个正整数NN,代表全1序列的长度。

1≤N≤200

Output

对于每组测试数据,输出一个整数,代表由题目中所给定的全1序列所能形成的新序列的数量。

Sample Input
  1. 1
  2. 3
  3. 5
Sample Output
  1. 1
  2. 3
  3. 8
Hint

如果序列是:(111)。可以构造出如下三个新序列:(111), (21), (12)。

仔细写一下,是一个斐波那契数列哦,当然要有大数(存在n==0)不要输出,换行就行!

  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <string.h>
  4. using namespace std;
  5.  
  6. #define DIGIT 4 //四位隔开,即万进制
  7. #define DEPTH 10000 //万进制
  8. #define MAX 100 //题目最大位数/4,要不大直接设为最大位数也行
  9. typedef int bignum_t[MAX+];
  10.  
  11. /************************************************************************/
  12. /* 读取操作数,对操作数进行处理存储在数组里 */
  13. /************************************************************************/
  14. int read(bignum_t a,istream&is=cin)
  15. {
  16. char buf[MAX*DIGIT+],ch ;
  17. int i,j ;
  18. memset((void*)a,,sizeof(bignum_t));
  19. if(!(is>>buf))return ;
  20. for(a[]=strlen(buf),i=a[]/-;i>=;i--)
  21. ch=buf[i],buf[i]=buf[a[]--i],buf[a[]--i]=ch ;
  22. for(a[]=(a[]+DIGIT-)/DIGIT,j=strlen(buf);j<a[]*DIGIT;buf[j++]='');
  23. for(i=;i<=a[];i++)
  24. for(a[i]=,j=;j<DIGIT;j++)
  25. a[i]=a[i]*+buf[i*DIGIT--j]-'' ;
  26. for(;!a[a[]]&&a[]>;a[]--);
  27. return ;
  28. }
  29.  
  30. void write(const bignum_t a,ostream&os=cout)
  31. {
  32. int i,j ;
  33. for(os<<a[i=a[]],i--;i;i--)
  34. for(j=DEPTH/;j;j/=)
  35. os<<a[i]/j% ;
  36. }
  37.  
  38. int comp(const bignum_t a,const bignum_t b)
  39. {
  40. int i ;
  41. if(a[]!=b[])
  42. return a[]-b[];
  43. for(i=a[];i;i--)
  44. if(a[i]!=b[i])
  45. return a[i]-b[i];
  46. return ;
  47. }
  48.  
  49. int comp(const bignum_t a,const int b)
  50. {
  51. int c[]=
  52. {
  53. }
  54. ;
  55. for(c[]=b;c[c[]]>=DEPTH;c[c[]+]=c[c[]]/DEPTH,c[c[]]%=DEPTH,c[]++);
  56. return comp(a,c);
  57. }
  58.  
  59. int comp(const bignum_t a,const int c,const int d,const bignum_t b)
  60. {
  61. int i,t=,O=-DEPTH* ;
  62. if(b[]-a[]<d&&c)
  63. return ;
  64. for(i=b[];i>d;i--)
  65. {
  66. t=t*DEPTH+a[i-d]*c-b[i];
  67. if(t>)return ;
  68. if(t<O)return ;
  69. }
  70. for(i=d;i;i--)
  71. {
  72. t=t*DEPTH-b[i];
  73. if(t>)return ;
  74. if(t<O)return ;
  75. }
  76. return t> ;
  77. }
  78. /************************************************************************/
  79. /* 大数与大数相加 */
  80. /************************************************************************/
  81. void add(bignum_t a,const bignum_t b)
  82. {
  83. int i ;
  84. for(i=;i<=b[];i++)
  85. if((a[i]+=b[i])>=DEPTH)
  86. a[i]-=DEPTH,a[i+]++;
  87. if(b[]>=a[])
  88. a[]=b[];
  89. else
  90. for(;a[i]>=DEPTH&&i<a[];a[i]-=DEPTH,i++,a[i]++);
  91. a[]+=(a[a[]+]>);
  92. }
  93. /************************************************************************/
  94. /* 大数与小数相加 */
  95. /************************************************************************/
  96. void add(bignum_t a,const int b)
  97. {
  98. int i= ;
  99. for(a[]+=b;a[i]>=DEPTH&&i<a[];a[i+]+=a[i]/DEPTH,a[i]%=DEPTH,i++);
  100. for(;a[a[]]>=DEPTH;a[a[]+]=a[a[]]/DEPTH,a[a[]]%=DEPTH,a[]++);
  101. }
  102. /************************************************************************/
  103. /* 大数相减(被减数>=减数) */
  104. /************************************************************************/
  105. void sub(bignum_t a,const bignum_t b)
  106. {
  107. int i ;
  108. for(i=;i<=b[];i++)
  109. if((a[i]-=b[i])<)
  110. a[i+]--,a[i]+=DEPTH ;
  111. for(;a[i]<;a[i]+=DEPTH,i++,a[i]--);
  112. for(;!a[a[]]&&a[]>;a[]--);
  113. }
  114. /************************************************************************/
  115. /* 大数减去小数(被减数>=减数) */
  116. /************************************************************************/
  117. void sub(bignum_t a,const int b)
  118. {
  119. int i= ;
  120. for(a[]-=b;a[i]<;a[i+]+=(a[i]-DEPTH+)/DEPTH,a[i]-=(a[i]-DEPTH+)/DEPTH*DEPTH,i++);
  121. for(;!a[a[]]&&a[]>;a[]--);
  122. }
  123.  
  124. void sub(bignum_t a,const bignum_t b,const int c,const int d)
  125. {
  126. int i,O=b[]+d ;
  127. for(i=+d;i<=O;i++)
  128. if((a[i]-=b[i-d]*c)<)
  129. a[i+]+=(a[i]-DEPTH+)/DEPTH,a[i]-=(a[i]-DEPTH+)/DEPTH*DEPTH ;
  130. for(;a[i]<;a[i+]+=(a[i]-DEPTH+)/DEPTH,a[i]-=(a[i]-DEPTH+)/DEPTH*DEPTH,i++);
  131. for(;!a[a[]]&&a[]>;a[]--);
  132. }
  133. /************************************************************************/
  134. /* 大数相乘,读入被乘数a,乘数b,结果保存在c[] */
  135. /************************************************************************/
  136. void mul(bignum_t c,const bignum_t a,const bignum_t b)
  137. {
  138. int i,j ;
  139. memset((void*)c,,sizeof(bignum_t));
  140. for(c[]=a[]+b[]-,i=;i<=a[];i++)
  141. for(j=;j<=b[];j++)
  142. if((c[i+j-]+=a[i]*b[j])>=DEPTH)
  143. c[i+j]+=c[i+j-]/DEPTH,c[i+j-]%=DEPTH ;
  144. for(c[]+=(c[c[]+]>);!c[c[]]&&c[]>;c[]--);
  145. }
  146. /************************************************************************/
  147. /* 大数乘以小数,读入被乘数a,乘数b,结果保存在被乘数 */
  148. /************************************************************************/
  149. void mul(bignum_t a,const int b)
  150. {
  151. int i ;
  152. for(a[]*=b,i=;i<=a[];i++)
  153. {
  154. a[i]*=b ;
  155. if(a[i-]>=DEPTH)
  156. a[i]+=a[i-]/DEPTH,a[i-]%=DEPTH ;
  157. }
  158. for(;a[a[]]>=DEPTH;a[a[]+]=a[a[]]/DEPTH,a[a[]]%=DEPTH,a[]++);
  159. for(;!a[a[]]&&a[]>;a[]--);
  160. }
  161.  
  162. void mul(bignum_t b,const bignum_t a,const int c,const int d)
  163. {
  164. int i ;
  165. memset((void*)b,,sizeof(bignum_t));
  166. for(b[]=a[]+d,i=d+;i<=b[];i++)
  167. if((b[i]+=a[i-d]*c)>=DEPTH)
  168. b[i+]+=b[i]/DEPTH,b[i]%=DEPTH ;
  169. for(;b[b[]+];b[]++,b[b[]+]=b[b[]]/DEPTH,b[b[]]%=DEPTH);
  170. for(;!b[b[]]&&b[]>;b[]--);
  171. }
  172. /**************************************************************************/
  173. /* 大数相除,读入被除数a,除数b,结果保存在c[]数组 */
  174. /* 需要comp()函数 */
  175. /**************************************************************************/
  176. void div(bignum_t c,bignum_t a,const bignum_t b)
  177. {
  178. int h,l,m,i ;
  179. memset((void*)c,,sizeof(bignum_t));
  180. c[]=(b[]<a[]+)?(a[]-b[]+): ;
  181. for(i=c[];i;sub(a,b,c[i]=m,i-),i--)
  182. for(h=DEPTH-,l=,m=(h+l+)>>;h>l;m=(h+l+)>>)
  183. if(comp(b,m,i-,a))h=m- ;
  184. else l=m ;
  185. for(;!c[c[]]&&c[]>;c[]--);
  186. c[]=c[]>?c[]: ;
  187. }
  188.  
  189. void div(bignum_t a,const int b,int&c)
  190. {
  191. int i ;
  192. for(c=,i=a[];i;c=c*DEPTH+a[i],a[i]=c/b,c%=b,i--);
  193. for(;!a[a[]]&&a[]>;a[]--);
  194. }
  195. /************************************************************************/
  196. /* 大数平方根,读入大数a,结果保存在b[]数组里 */
  197. /* 需要comp()函数 */
  198. /************************************************************************/
  199. void sqrt(bignum_t b,bignum_t a)
  200. {
  201. int h,l,m,i ;
  202. memset((void*)b,,sizeof(bignum_t));
  203. for(i=b[]=(a[]+)>>;i;sub(a,b,m,i-),b[i]+=m,i--)
  204. for(h=DEPTH-,l=,b[i]=m=(h+l+)>>;h>l;b[i]=m=(h+l+)>>)
  205. if(comp(b,m,i-,a))h=m- ;
  206. else l=m ;
  207. for(;!b[b[]]&&b[]>;b[]--);
  208. for(i=;i<=b[];b[i++]>>=);
  209. }
  210. /************************************************************************/
  211. /* 返回大数的长度 */
  212. /************************************************************************/
  213. int length(const bignum_t a)
  214. {
  215. int t,ret ;
  216. for(ret=(a[]-)*DIGIT,t=a[a[]];t;t/=,ret++);
  217. return ret>?ret: ;
  218. }
  219. /************************************************************************/
  220. /* 返回指定位置的数字,从低位开始数到第b位,返回b位上的数 */
  221. /************************************************************************/
  222. int digit(const bignum_t a,const int b)
  223. {
  224. int i,ret ;
  225. for(ret=a[(b-)/DIGIT+],i=(b-)%DIGIT;i;ret/=,i--);
  226. return ret% ;
  227. }
  228. /************************************************************************/
  229. /* 返回大数末尾0的个数 */
  230. /************************************************************************/
  231. int zeronum(const bignum_t a)
  232. {
  233. int ret,t ;
  234. for(ret=;!a[ret+];ret++);
  235. for(t=a[ret+],ret*=DIGIT;!(t%);t/=,ret++);
  236. return ret ;
  237. }
  238.  
  239. void comp(int*a,const int l,const int h,const int d)
  240. {
  241. int i,j,t ;
  242. for(i=l;i<=h;i++)
  243. for(t=i,j=;t>;j++)
  244. while(!(t%j))
  245. a[j]+=d,t/=j ;
  246. }
  247.  
  248. void convert(int*a,const int h,bignum_t b)
  249. {
  250. int i,j,t= ;
  251. memset(b,,sizeof(bignum_t));
  252. for(b[]=b[]=,i=;i<=h;i++)
  253. if(a[i])
  254. for(j=a[i];j;t*=i,j--)
  255. if(t*i>DEPTH)
  256. mul(b,t),t= ;
  257. mul(b,t);
  258. }
  259. /************************************************************************/
  260. /* 组合数 */
  261. /************************************************************************/
  262. void combination(bignum_t a,int m,int n)
  263. {
  264. int*t=new int[m+];
  265. memset((void*)t,,sizeof(int)*(m+));
  266. comp(t,n+,m,);
  267. comp(t,,m-n,-);
  268. convert(t,m,a);
  269. delete[]t ;
  270. }
  271. /************************************************************************/
  272. /* 排列数 */
  273. /************************************************************************/
  274. void permutation(bignum_t a,int m,int n)
  275. {
  276. int i,t= ;
  277. memset(a,,sizeof(bignum_t));
  278. a[]=a[]= ;
  279. for(i=m-n+;i<=m;t*=i++)
  280. if(t*i>DEPTH)
  281. mul(a,t),t= ;
  282. mul(a,t);
  283. }
  284.  
  285. #define SGN(x) ((x)>0?1:((x)<0?-1:0))
  286. #define ABS(x) ((x)>0?(x):-(x))
  287.  
  288. int read(bignum_t a,int&sgn,istream&is=cin)
  289. {
  290. char str[MAX*DIGIT+],ch,*buf ;
  291. int i,j ;
  292. memset((void*)a,,sizeof(bignum_t));
  293. if(!(is>>str))return ;
  294. buf=str,sgn= ;
  295. if(*buf=='-')sgn=-,buf++;
  296. for(a[]=strlen(buf),i=a[]/-;i>=;i--)
  297. ch=buf[i],buf[i]=buf[a[]--i],buf[a[]--i]=ch ;
  298. for(a[]=(a[]+DIGIT-)/DIGIT,j=strlen(buf);j<a[]*DIGIT;buf[j++]='');
  299. for(i=;i<=a[];i++)
  300. for(a[i]=,j=;j<DIGIT;j++)
  301. a[i]=a[i]*+buf[i*DIGIT--j]-'' ;
  302. for(;!a[a[]]&&a[]>;a[]--);
  303. if(a[]==&&!a[])sgn= ;
  304. return ;
  305. }
  306. struct bignum
  307. {
  308. bignum_t num ;
  309. int sgn ;
  310. public :
  311. inline bignum()
  312. {
  313. memset(num,,sizeof(bignum_t));
  314. num[]= ;
  315. sgn= ;
  316. }
  317. inline int operator!()
  318. {
  319. return num[]==&&!num[];
  320. }
  321. inline bignum&operator=(const bignum&a)
  322. {
  323. memcpy(num,a.num,sizeof(bignum_t));
  324. sgn=a.sgn ;
  325. return*this ;
  326. }
  327. inline bignum&operator=(const int a)
  328. {
  329. memset(num,,sizeof(bignum_t));
  330. num[]= ;
  331. sgn=SGN (a);
  332. add(num,sgn*a);
  333. return*this ;
  334. }
  335. ;
  336. inline bignum&operator+=(const bignum&a)
  337. {
  338. if(sgn==a.sgn)add(num,a.num);
  339. else if
  340. (sgn&&a.sgn)
  341. {
  342. int ret=comp(num,a.num);
  343. if(ret>)sub(num,a.num);
  344. else if(ret<)
  345. {
  346. bignum_t t ;
  347. memcpy(t,num,sizeof(bignum_t));
  348. memcpy(num,a.num,sizeof(bignum_t));
  349. sub (num,t);
  350. sgn=a.sgn ;
  351. }
  352. else memset(num,,sizeof(bignum_t)),num[]=,sgn= ;
  353. }
  354. else if(!sgn)
  355. memcpy(num,a.num,sizeof(bignum_t)),sgn=a.sgn ;
  356. return*this ;
  357. }
  358. inline bignum&operator+=(const int a)
  359. {
  360. if(sgn*a>)add(num,ABS(a));
  361. else if(sgn&&a)
  362. {
  363. int ret=comp(num,ABS(a));
  364. if(ret>)sub(num,ABS(a));
  365. else if(ret<)
  366. {
  367. bignum_t t ;
  368. memcpy(t,num,sizeof(bignum_t));
  369. memset(num,,sizeof(bignum_t));
  370. num[]= ;
  371. add(num,ABS (a));
  372. sgn=-sgn ;
  373. sub(num,t);
  374. }
  375. else memset(num,,sizeof(bignum_t)),num[]=,sgn= ;
  376. }
  377. else if
  378. (!sgn)sgn=SGN(a),add(num,ABS(a));
  379. return*this ;
  380. }
  381. inline bignum operator+(const bignum&a)
  382. {
  383. bignum ret ;
  384. memcpy(ret.num,num,sizeof (bignum_t));
  385. ret.sgn=sgn ;
  386. ret+=a ;
  387. return ret ;
  388. }
  389. inline bignum operator+(const int a)
  390. {
  391. bignum ret ;
  392. memcpy(ret.num,num,sizeof (bignum_t));
  393. ret.sgn=sgn ;
  394. ret+=a ;
  395. return ret ;
  396. }
  397. inline bignum&operator-=(const bignum&a)
  398. {
  399. if(sgn*a.sgn<)add(num,a.num);
  400. else if
  401. (sgn&&a.sgn)
  402. {
  403. int ret=comp(num,a.num);
  404. if(ret>)sub(num,a.num);
  405. else if(ret<)
  406. {
  407. bignum_t t ;
  408. memcpy(t,num,sizeof(bignum_t));
  409. memcpy(num,a.num,sizeof(bignum_t));
  410. sub(num,t);
  411. sgn=-sgn ;
  412. }
  413. else memset(num,,sizeof(bignum_t)),num[]=,sgn= ;
  414. }
  415. else if(!sgn)add (num,a.num),sgn=-a.sgn ;
  416. return*this ;
  417. }
  418. inline bignum&operator-=(const int a)
  419. {
  420. if(sgn*a<)add(num,ABS(a));
  421. else if(sgn&&a)
  422. {
  423. int ret=comp(num,ABS(a));
  424. if(ret>)sub(num,ABS(a));
  425. else if(ret<)
  426. {
  427. bignum_t t ;
  428. memcpy(t,num,sizeof(bignum_t));
  429. memset(num,,sizeof(bignum_t));
  430. num[]= ;
  431. add(num,ABS(a));
  432. sub(num,t);
  433. sgn=-sgn ;
  434. }
  435. else memset(num,,sizeof(bignum_t)),num[]=,sgn= ;
  436. }
  437. else if
  438. (!sgn)sgn=-SGN(a),add(num,ABS(a));
  439. return*this ;
  440. }
  441. inline bignum operator-(const bignum&a)
  442. {
  443. bignum ret ;
  444. memcpy(ret.num,num,sizeof(bignum_t));
  445. ret.sgn=sgn ;
  446. ret-=a ;
  447. return ret ;
  448. }
  449. inline bignum operator-(const int a)
  450. {
  451. bignum ret ;
  452. memcpy(ret.num,num,sizeof(bignum_t));
  453. ret.sgn=sgn ;
  454. ret-=a ;
  455. return ret ;
  456. }
  457. inline bignum&operator*=(const bignum&a)
  458. {
  459. bignum_t t ;
  460. mul(t,num,a.num);
  461. memcpy(num,t,sizeof(bignum_t));
  462. sgn*=a.sgn ;
  463. return*this ;
  464. }
  465. inline bignum&operator*=(const int a)
  466. {
  467. mul(num,ABS(a));
  468. sgn*=SGN(a);
  469. return*this ;
  470. }
  471. inline bignum operator*(const bignum&a)
  472. {
  473. bignum ret ;
  474. mul(ret.num,num,a.num);
  475. ret.sgn=sgn*a.sgn ;
  476. return ret ;
  477. }
  478. inline bignum operator*(const int a)
  479. {
  480. bignum ret ;
  481. memcpy(ret.num,num,sizeof (bignum_t));
  482. mul(ret.num,ABS(a));
  483. ret.sgn=sgn*SGN(a);
  484. return ret ;
  485. }
  486. inline bignum&operator/=(const bignum&a)
  487. {
  488. bignum_t t ;
  489. div(t,num,a.num);
  490. memcpy (num,t,sizeof(bignum_t));
  491. sgn=(num[]==&&!num[])?:sgn*a.sgn ;
  492. return*this ;
  493. }
  494. inline bignum&operator/=(const int a)
  495. {
  496. int t ;
  497. div(num,ABS(a),t);
  498. sgn=(num[]==&&!num [])?:sgn*SGN(a);
  499. return*this ;
  500. }
  501. inline bignum operator/(const bignum&a)
  502. {
  503. bignum ret ;
  504. bignum_t t ;
  505. memcpy(t,num,sizeof(bignum_t));
  506. div(ret.num,t,a.num);
  507. ret.sgn=(ret.num[]==&&!ret.num[])?:sgn*a.sgn ;
  508. return ret ;
  509. }
  510. inline bignum operator/(const int a)
  511. {
  512. bignum ret ;
  513. int t ;
  514. memcpy(ret.num,num,sizeof(bignum_t));
  515. div(ret.num,ABS(a),t);
  516. ret.sgn=(ret.num[]==&&!ret.num[])?:sgn*SGN(a);
  517. return ret ;
  518. }
  519. inline bignum&operator%=(const bignum&a)
  520. {
  521. bignum_t t ;
  522. div(t,num,a.num);
  523. if(num[]==&&!num[])sgn= ;
  524. return*this ;
  525. }
  526. inline int operator%=(const int a)
  527. {
  528. int t ;
  529. div(num,ABS(a),t);
  530. memset(num,,sizeof (bignum_t));
  531. num[]= ;
  532. add(num,t);
  533. return t ;
  534. }
  535. inline bignum operator%(const bignum&a)
  536. {
  537. bignum ret ;
  538. bignum_t t ;
  539. memcpy(ret.num,num,sizeof(bignum_t));
  540. div(t,ret.num,a.num);
  541. ret.sgn=(ret.num[]==&&!ret.num [])?:sgn ;
  542. return ret ;
  543. }
  544. inline int operator%(const int a)
  545. {
  546. bignum ret ;
  547. int t ;
  548. memcpy(ret.num,num,sizeof(bignum_t));
  549. div(ret.num,ABS(a),t);
  550. memset(ret.num,,sizeof(bignum_t));
  551. ret.num[]= ;
  552. add(ret.num,t);
  553. return t ;
  554. }
  555. inline bignum&operator++()
  556. {
  557. *this+= ;
  558. return*this ;
  559. }
  560. inline bignum&operator--()
  561. {
  562. *this-= ;
  563. return*this ;
  564. }
  565. ;
  566. inline int operator>(const bignum&a)
  567. {
  568. return sgn>?(a.sgn>?comp(num,a.num)>:):(sgn<?(a.sgn<?comp(num,a.num)<:):a.sgn<);
  569. }
  570. inline int operator>(const int a)
  571. {
  572. return sgn>?(a>?comp(num,a)>:):(sgn<?(a<?comp(num,-a)<:):a<);
  573. }
  574. inline int operator>=(const bignum&a)
  575. {
  576. return sgn>?(a.sgn>?comp(num,a.num)>=:):(sgn<?(a.sgn<?comp(num,a.num)<=:):a.sgn<=);
  577. }
  578. inline int operator>=(const int a)
  579. {
  580. return sgn>?(a>?comp(num,a)>=:):(sgn<?(a<?comp(num,-a)<=:):a<=);
  581. }
  582. inline int operator<(const bignum&a)
  583. {
  584. return sgn<?(a.sgn<?comp(num,a.num)>:):(sgn>?(a.sgn>?comp(num,a.num)<:):a.sgn>);
  585. }
  586. inline int operator<(const int a)
  587. {
  588. return sgn<?(a<?comp(num,-a)>:):(sgn>?(a>?comp(num,a)<:):a>);
  589. }
  590. inline int operator<=(const bignum&a)
  591. {
  592. return sgn<?(a.sgn<?comp(num,a.num)>=:):(sgn>?(a.sgn>?comp(num,a.num)<=:):a.sgn>=);
  593. }
  594. inline int operator<=(const int a)
  595. {
  596. return sgn<?(a<?comp(num,-a)>=:):
  597. (sgn>?(a>?comp(num,a)<=:):a>=);
  598. }
  599. inline int operator==(const bignum&a)
  600. {
  601. return(sgn==a.sgn)?!comp(num,a.num): ;
  602. }
  603. inline int operator==(const int a)
  604. {
  605. return(sgn*a>=)?!comp(num,ABS(a)): ;
  606. }
  607. inline int operator!=(const bignum&a)
  608. {
  609. return(sgn==a.sgn)?comp(num,a.num): ;
  610. }
  611. inline int operator!=(const int a)
  612. {
  613. return(sgn*a>=)?comp(num,ABS(a)): ;
  614. }
  615. inline int operator[](const int a)
  616. {
  617. return digit(num,a);
  618. }
  619. friend inline istream&operator>>(istream&is,bignum&a)
  620. {
  621. read(a.num,a.sgn,is);
  622. return is ;
  623. }
  624. friend inline ostream&operator<<(ostream&os,const bignum&a)
  625. {
  626. if(a.sgn<)
  627. os<<'-' ;
  628. write(a.num,os);
  629. return os ;
  630. }
  631. friend inline bignum sqrt(const bignum&a)
  632. {
  633. bignum ret ;
  634. bignum_t t ;
  635. memcpy(t,a.num,sizeof(bignum_t));
  636. sqrt(ret.num,t);
  637. ret.sgn=ret.num[]!=||ret.num[];
  638. return ret ;
  639. }
  640. friend inline bignum sqrt(const bignum&a,bignum&b)
  641. {
  642. bignum ret ;
  643. memcpy(b.num,a.num,sizeof(bignum_t));
  644. sqrt(ret.num,b.num);
  645. ret.sgn=ret.num[]!=||ret.num[];
  646. b.sgn=b.num[]!=||ret.num[];
  647. return ret ;
  648. }
  649. inline int length()
  650. {
  651. return :: length(num);
  652. }
  653. inline int zeronum()
  654. {
  655. return :: zeronum(num);
  656. }
  657. inline bignum C(const int m,const int n)
  658. {
  659. combination(num,m,n);
  660. sgn= ;
  661. return*this ;
  662. }
  663. inline bignum P(const int m,const int n)
  664. {
  665. permutation(num,m,n);
  666. sgn= ;
  667. return*this ;
  668. }
  669. };
  670. int main()
  671. {
  672. bignum a[];
  673. a[]=;
  674. a[]=;
  675. int n;
  676. for(int i=;i<=;i++)
  677. {
  678. a[i]=a[i-]+a[i-];
  679. }
  680. while(cin>>n)
  681. {
    if(n==0)
    cout<<"\n";
    else
  682. cout<<a[n]<<endl;
  683. }
  684. return ;
  685. }

2016"百度之星" - 资格赛(Astar Round1) B的更多相关文章

  1. 2016百度之星 资格赛ABCDE

    看题:http://bestcoder.hdu.edu.cn/contests/contest_show.php?cid=690 交题:http://acm.hdu.edu.cn/search.php ...

  2. HDU 5688:2016"百度之星" - 资格赛 Problem D

    原文链接:https://www.dreamwings.cn/hdu5688/2650.html Problem D Time Limit: 2000/1000 MS (Java/Others)    ...

  3. HDU 5686:2016"百度之星" - 资格赛 Problem B

    原文链接:https://www.dreamwings.cn/hdu5686/2645.html Problem B Time Limit: 2000/1000 MS (Java/Others)    ...

  4. HDU 5685:2016"百度之星" - 资格赛 Problem A

    原文链接:https://www.dreamwings.cn/hdu5685/2637.html Problem A Time Limit: 2000/1000 MS (Java/Others)    ...

  5. 2016"百度之星" - 资格赛(Astar Round1)

    逆元 1001 Problem A 求前缀哈希和逆元 #include <bits/stdc++.h> typedef long long ll; const int MOD = 9973 ...

  6. 2016"百度之星" - 资格赛(Astar Round1) 1004

    思路:题目很简单,直接用map记录每个字符串的个数就可以了.记得对每个字符串先sort(). AC代码: #include <cstdio> #include <stdlib.h&g ...

  7. 2016"百度之星" - 资格赛(Astar Round1) 1001

    思路:第一个做法就是:每读入起始位置i和结束位置j,就从这位置i到位置j计算,可是TLE了,后面我想想要是我输入一个最长的字符串,且以最大次数计算开始位置1到结束位置100000,那么这计算量是很大的 ...

  8. 2016"百度之星" - 资格赛(Astar Round1) Problem E

    简单模拟题,耐心写就能过. #include <stdio.h> #include <math.h> #include<cstring> #include<c ...

  9. 2016"百度之星" - 资格赛(Astar Round1) Problem C

    字典树. 插入的时候update一下节点出现的次数. delete的时候,先把前缀之后的全删了.然后看前缀最后一个节点出现了几次,然后前缀上每个节点的次数都减去这个次数. 前缀从上到下再检查一遍,如果 ...

  10. 2016"百度之星" - 资格赛(Astar Round1) Problem D

    排个序,map直接搞. #include <stdio.h> #include <math.h> #include<cstring> #include<cma ...

随机推荐

  1. request 10.0 模块安装

     https://pypi.python.org/packages/49/6f/183063f01aae1e025cf0130772b55848750a2f3a89bfa11b385b35d7329d ...

  2. set源码之心得

    C++的STL很强大,强大到我只愿慵懒地去使用而不知其所以然.直到李师问我,我的回答被李师否定,我方才意识到自己是多么地浅陋.希望自己有空抽时间把STL源码给研究一下,化为自己真正可以掌控的力量. s ...

  3. a标签中href=""的几种用法(转)

    a标签中href=""的几种用法   标签: html / a标签 / javascript 46371 众所周知,a标签的最重要功能是实现超链接和锚点.而且,大多数人认为a标签最 ...

  4. oracle创建完实例删除的时候报ORA-01031:insufficient privileges错误,解决办法

    创建了一个数据库,想删除确报了一个ORA-01031:insufficient privileges错误 查了好久,总算解决了,原因是我的电脑登录账户不在ORA_DBA系统群组中,添加进去完美删除! ...

  5. 使用Get进行Http通信

    --------------siwuxie095 有道翻译官网:http://fanyi.youdao.com/ 找到官网页面下方的 有道翻译API,选择 调用数据接口,申请一个 key (申请内容可 ...

  6. C++字符串流保存数据

    文件流是以外存文件为输入输出对象的数据流.字符串流是以内存中用户定义的字符数组(字符串)为输入输出对象的. 建立输出字符串流: ostrstream strout(c,sizeof(c));第一个参数 ...

  7. Angular01 利用grunt搭建自动web前端开发环境、利用angular-cli搭建web前端项目

    搭建angular开发环境 一.下载并安装node 官网地址:点击前往 二.利用npm安装cnpm 安装好node后就可以使用npm命令啦 查看版本:npm -v 安装cnpm:npm install ...

  8. bzoj2134 错选单位

    传送门 题目 Input n很大,为了避免读入耗时太多, 输入文件只有5个整数参数n, A, B, C, a1, 由上交的程序产生数列a. 下面给出pascal/C/C++的读入语句和产生序列的语句( ...

  9. 前端基础 之JS

    浏览目录 JavaScript语法基础 JavaScript数据类型及类型查询 JavaScript运算符 JavaScript流程控制 JavaScript函数 词法分析 JavaScript内置对 ...

  10. 第四章输入/输出(I/O)4.2PCL中I/O模块及类介绍

    PCL中I/O库提供了点云文件输入输出相关的操作类,并封装了OpenNI兼容的设备源数据获取接口,可直接从众多感知设备获取点云图像等数据.I/O模块利用21个类和28个函数实现了对点云的获取.读入.存 ...