Back Gear | Digital Triangle 2

Source: Internet
Author: User

Describe

Digital triangles
Request to go to the last mod 100 max
Input format

Line 1th N, which represents n rows <=25
2nd to n+1 behavior each weight value
Output format

MoD 100 Maximum Value

Test Sample 1

Input
2
1
99 98

Output
99

Topic Analysis:

The digital triangle is a classic topic, so it has a lot of hardening versions. I made a 2--4. Although they are much the same, I still send it up so that we can expand our thinking. (In fact, my Code p,c interaction for a reason, because I started the summer vacation to C, at the same time began to brush the problem, so some questions are p, some of the problem is C)

So back to the chase. This problem I used a three-dimensional Boolean array f[i][j][k]. Using the idea of hash, directly save mod100 can arrive. The state transfer equation is very well written. The last enumeration of K is OK.

Source:

varI,j,k,n:longint; F:Array[0.. -,0.. -,0.. About] ofBoolean; A:Array[0.. -,0.. -] ofLongint;beginFillchar (F,sizeof (f), false);  READLN (n);  fori:=1  toN Do     forj:=1  toI Doread (a[i,j]); f[1,1, a[1,1]MoD  -]:=true;  fori:=2  toN Do     forj:=1  toI Do       fork:=0  to  About  Do        begin          iff[i-1, J,k] ThenF[i,j, (K+a[i,j])MoD  -]:=true; iff[i-1, J-1K ThenF[i,j, (K+a[i,j])MoD  -]:=true; End;  fori:= About Downto 0  Do     forj:=1  toN Do      ifF[n,j,i] Then        beginWriteln (i);        Exit End;End.

Back Gear | Digital Triangle 2

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.