集訓隊作業(yè)解題報告_第1頁
集訓隊作業(yè)解題報告_第2頁
集訓隊作業(yè)解題報告_第3頁
集訓隊作業(yè)解題報告_第4頁
全文預覽已結束

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

1、題目來源Ural 1590 Bacons Cipher問題描述輸入一個串,輸出它的不同子串的個數(shù)。算法依次統(tǒng)計長度為 1、2、3n 的子串中重復的個數(shù)。算法證明無需證明。算法實現(xiàn)沒有實現(xiàn)上。源代碼const maxn=10000;var a:arraya.zof long;f:array1.maxnof;l1,l2:array1.maxnof longst:ansistring;n,i,j,k,s,ans:longbegin;/ assign(input,input.txt); reset(input);readln(st); for i:=1 to ans:=0;for i:=1 ton:=

2、length(st);n-1 do l1i:=i+1; l1n:=0;n do begins:=0; fillchar(f,sizeof(f),0); fillchar(l2,sizeof(l2),0);for j:=1 to n-i+1f not fj then begink:=j; whileiffillchar(a,sizeof(a),0); (k0)and(k0 then begin l2astk+i-1:=k; inc(s);end;astk+i-1:=k; fk:=true; k:=l1k; end;end;l1:=l2; ans:=ans+n-i+1-s; end;wriend.

3、n(ans);原題描述:1590. Bacons CypherTime Limit: 1.0 second Memory Limit: 64 MBProgrammer Vasya was down on his luck. Instead of a vacation, he was sent to a scientific conference.“It is nesary to increase your competence,” hiss said, “its an important conference on cryptography, and its held in France, w

4、herethey used encryptiondays of Viete.”he days of de Richeu and cracked codesheOne of the talks at the conference was about the attempts to solve Baconscyphers. The speakroed a hypothesist the key to Baconssecrets could be found if allyzed.sible substrings of Bacons works were“But there are too many

5、 of them!” Vasya expressed his astonishment.“Not as many as you think,” the speaker answered, “count them all and youll see it yourself.”t evening Vasya found on the Web the complete set of Bacons works.He wrote a programt converted the textso one long string byremoving all linebreaks, spa, and punc

6、tuation marks. And now Vasya isconfused because he doesnt know how to calculate the number of different substrings of this string.InputYou are given a nonempty string consisting of lowercase English letters.The string is no longern 5000 symbols.OutputOutput the number of different substrings of this string.SleinputoutputProblem Author: Alex Ge

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論