跳到主要內容

發表文章

目前顯示的是 3月, 2015的文章

UVA11538

Link :  http://uva.onlinejudge.org/external/115/11538.pdf ----------------------------------------------------------------------------------------------------------- Hint :         ※ 假設M邊較長               總共有三種方法可以攻擊敵人,行、列、斜向。         行與列:         黑后有M*N種位置選擇,選擇M以後白后就只剩下N-1個位置,得 M*N(N-1),etc         得 N*M(M-1),整合為 N*M( N + M - 2) 。         斜向:最長的斜向一共有 M - N + 1條,假定最長斜向為 n length         可得1,2,3......n-1,nnnnnn(M-N+1條) ,n-1,n-2,.......1,令 1 ~ n-1 加總為 i         故可得一共有 2 *  ∑ i ( i-1 ) (1<= i <=n-1) 條斜向(不含最長)         最長的斜向:N ( N-1 ) ( M - N + 1) ,選了一個N即剩下N-1種選擇         斜向總數:( 2 *  ∑ i ( i - 1 ) (1<= i <=n-1) + N( N - 1 ) ( M - N + 1) )  * 2 (正反斜)                                                                 ↑↓ (整理結果)                                             2 * N * ( N-1 ) * (3 * M - N - 1) / 3         # import java.util.Scanner; public class UVA11538 { public static void main(String[] args) { // TODO Auto-generated metho

UVA409

  Excuses, Excuses!   Judge Ito is having a problem with people subpoenaed for jury duty giving rather lame excuses in order to avoid serving. In order to reduce the amount of time required listening to goofy excuses, Judge Ito has asked that you write a program that will search for a list of keywords in a list of excuses identifying lame excuses. Keywords can be matched in an excuse regardless of case. Input Input to your program will consist of multiple sets of data. Line 1 of each set will contain exactly two integers. The first number (   ) defines the number of keywords to be used in the search. The second number (   ) defines the number of excuses in the set to be searched. Lines 2 through  K +1 each contain exactly one keyword. Lines  K +2 through  K +1+ E  each contain exactly one excuse. All keywords in the keyword list will contain only contiguous lower case alphabetic characters of length  L  (   ) and will occupy columns 1 through  L  in the input line. Al