vj1455 最小与最大

Vj1455 最小与最大

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
//±ÉÈ˵ķ½·¨ //dp //(a+b) mod c =( ( a mod c ) + ( b mod c ) ) mod c //Éè f[ i , t ] Ϊǰ i ¸öÊý×Ö mod m = t ÐèÒªµÄ×îС³ËºÅ //Éè md [ i , j ] Ϊ´Ó i µ½ j mod m µÄÖµ md [ i , j ] = ( md [ i , j-1 ] * 10 + a[ j ] ) mod m //f[ i , t ] = min ( f[ k , j ] ) + 1 ( k < i ) //ÆäÖÐ f[ k , j ] * md [ k+1 , i ] mod m = t / const maxm=50; maxn=1000; var n,m:integer; a:array[0. .maxn] of integer; f:array[0. .maxn,0. .maxm-1] of integer; md:array[0. .maxn,0. .maxn] of integer; procedure init; var i:integer; ch:char; begin while not eoln do begin read(ch); inc(n); a[n]:=ord(ch)-48; end; readln; readln(m); end; procedure main; var i,j,k,t:integer; begin for i:=1 to n do for j:=i to n do md[i,j]:=(md[i,j-1]*10+a[j]) mod m; for i:=1 to n do
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/21/2011 for the course CS 001 taught by Professor 001 during the Spring '11 term at Shandong University.

Page1 / 2

Vj1455 最小与最大

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online