Dynamic planning of TYVJ P3119 nuclear power plant

Source: Internet
Author: User

title: http://tyvj.cn/p/3119 P3119Nuclear power plant problem time: 1000ms/Space: 65536kib/java class Name: Main description

A nuclear power plant has n a pit of nuclear material, and the pits are arranged in a straight line. If the nuclear material is placed in a continuous M-pit, an explosion will occur and the nuclear substance may not be released in certain pits.
Mission: For a given N and m, the total number of solutions for placing nuclear matter without explosion

Input format

Input file only one line, two positive integers n,m (1

Output format

The output file has only a positive integer s, which indicates the total number of scenarios.

Test Sample 1 input
4 3
Output
-
Solution: Dynamic Programming F[i][j] for the first, I put the number of J explosives. Mathematical Methods not Qaq
1#include <bits/stdc++.h>2 using namespacestd;3 #defineLL Long Long4LL f[ -][6];5 intMain ()6 {7Freopen ("nucle.in","R", stdin);8Freopen ("Nucle.out","W", stdout);9 LL ans,n,m,i,j,k;Tenscanf"%lld%lld",&n,&m); OneMemset (F,0,sizeof(f));//F[i][j] For the first I, put the number of J explosives. Af[1][0]=f[1][1]=1; -      for(i=2; i<=n;i++) -     { the          for(j=0; j<m;j++) f[i][0]+=f[i-1][j]; -          for(j=0; j<m;j++) f[i][j]+=f[i-1][j-1]; -     } -ans=0; +      for(i=0; i<m;i++) ans+=F[n][i]; -printf"%lld", ans); +     /*the mathematical method of the error A For (i=1;i<=n;i++) ans*=2; at k=n-m+1; - if (k<=0) printf ("%lld", ans); - Else -     { - For (i=k;i>=1;i--) ans-=i; - printf ("%lld", ans); in     }*/ -     return 0; to}

Dynamic planning of TYVJ P3119 nuclear power plant

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.