HDU 4389 X mod f (x) (Digital DP)

Source: Internet
Author: User

HDU 4389 X mod f (x) (Digital DP)

 
For the first time, you need to enumerate and then digit DP.
First, enumerate the sum of all numbers, that is, 1 ~ 81. Then, in the digital DP process, judge whether the sum of the enumerated numbers is the same as that of the enumerated numbers.
Dp [I] [j] [k] [h] indicates that, on the I-bit, the current number is j, and the enumerated number is k, the number of k modulo h for the current number pair.
The Code is as follows:

#include 
  
   #include 
   
    #include 
    
     #include 
     
      #include #include 
      
       #include
       #include 
        
         #include 
         
          using namespace std;#define LL __int64#define pi acos(-1.0)const int mod=1e9+7;const int INF=0x3f3f3f3f;const double eqs=1e-9;const int MAXN=200000+10;int dp[11][82][82][82], dig[11];int dfs(int cnt, int sum, int mods, int res, int maxd){ if(cnt==-1) return sum==mods&&res==0; if(sum>mods) return 0; if(maxd&&dp[cnt][sum][mods][res]!=-1) return dp[cnt][sum][mods][res]; int i, r=maxd?9:dig[cnt], ans=0; for(i=0;i<=r;i++){ ans+=dfs(cnt-1,sum+i,mods,(res*10+i)%mods,maxd||i
          
         
        
      
     
    
   
  

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.