[2016-04-14] [Codeforces] [630] C [Lucky Numbers]

Source: Internet
Author: User

    • Time: 2016-04-14-23:12:27 Thursday
    • Title Number: [2016-04-14][codeforces][630][c][Lucky Numbers]
    • Main topic:
      • Ask how many lucky numbers are within n digits
      • Lucky numbers: Numbers that contain only 7,8
    • Analysis:
      • The lucky number of the length I, each one has two possibilities, 7, 8, then the lucky number of length I has a total of $2^i$ may
      • Then all the lucky numbers within the length of n are $2^1 + 2^2 + ... + 2^n$,
  
 
  1. #include<cstdio>
  2. using namespace std;
  3. typedef long long ll;
  4. int main(){
  5. int n;ll ans = 0,cur = 1;
  6. scanf("%d",&n);
  7. while(n--){
  8. cur *= 2;
  9. ans += cur;
  10. }
  11. printf("%I64d\n",ans);
  12. }


From for notes (Wiz)

[2016-04-14] [Codeforces] [630] C [Lucky Numbers]

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.