2016年8月17日 星期三

Q10298 - Power Strings

https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1239

這題就是要找出最短子字串且算出有幾個重複
程式架構是子字串1~n一個一個去跟原本字串做比對
if(str.length()%sub.length()!=0)

      continue;
這個是判斷子字串是否為原本字串的倍數否就繼續執行下一個迴圈
補充若子字串用String會超時所以必須要用StringBuffer 每次append一個字母進去

沒有留言:

張貼留言