Codeforces 535B Tavas and Saddas digital DP

Source: Internet
Author: User

Test instructions: The definition of good number is only 4, and 7 is composed, give you a good a, and ask you how many good it is.

Problem-Solving ideas: The number of preprocessing bits is K, and then enumerate the digits of n, if this bit is 7 then the answer is to add this bit to 4 of the case number.

Problem Solving Code:

1 //File name:b.cpp2 //Author:darkdream3 //Created time:2015 April 15 Wednesday 00:46 48 seconds4 5#include <vector>6#include <list>7#include <map>8#include <Set>9#include <deque>Ten#include <stack> One#include <bitset> A#include <algorithm> -#include <functional> -#include <numeric> the#include <utility> -#include <sstream> -#include <iostream> -#include <iomanip> +#include <cstdio> -#include <cmath> +#include <cstdlib> A#include <cstring> at#include <ctime> - #defineLL Long Long -  - using namespacestd; - Charstr[ -]; - intLen; inLL sum[ the]; - intMain () { toscanf"%s", str); +     intLen =strlen (str); -LL ans=0 ;  theLL tmp =1;  *      for(inti =1; I <=9; i + +) $     {Panax NotoginsengTMP *=2;  -Sum[i] = sum[i-1] +tmp; the     } +Ans = sum[len-1]; A      for(inti =0; i < Len;i + +) the     { +       if(str[i]=='7')     -       { $Ans + =1<< (len-i-1); $       } -     } -printf"%lld\n", ans+1); the return 0; -}
View Code

Codeforces 535B Tavas and Saddas digital DP

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.