Beebot-big data problem, beebot-Big Data

Source: Internet
Author: User

Beebot-big data problem, beebot-Big Data

Source code:

1 # include <stdio. h> 2 3 unsigned long RoadWay (int n) {// defines the unsigned long type 4 unsigned long num1 = 1lu, num2 = 2lu; 5 unsigned long temp; 6 int I; 7 if (n = 2) {8 return 1lu; 9} else if (n = 3) {10 return 2lu; 11} else {12 for (I = 4; I <= n; ++ I) {13 temp = num1 + num2; 14 num1 = num2; 15 num2 = temp; 16} 17 return num2; 18} 19} 20 21 int main (int argc, const char * argv []) {22 // insert code here... 23 int n; 24 int a, B; 25 int len; 26 27 scanf ("% d", & n); 28 29 while (n> 0) {30 scanf ("% d", & a, & B); 31 if (a> 0 & a <B & B <50) {32 len = B-a; 33 printf ("% I64d \ n", RoadWay (1 + len); 34} else {35 break; 36} 37 -- n; 38} 39 40 return 0; 41}

Summary:

  • Do not use recursive algorithms as much as possible. You can use loop or tail recursion.
  • Int-> unsigned int = unsigned long-> unsigned long

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.