原创 android 添加監聽器失敗

錯誤代碼: myButton.setOnClickListener(new MyButtonListener () ); 解決: 包引入錯誤 import android.view.View.OnClickListener;

原创 貪心+好題+Yogurt factory

題目: 任務規定,一個酸奶製造廠,在n個星期內,分別要向外提供y[i]unit的酸奶。已知這個製造廠第i周製造每unit酸奶的費用爲c[i],儲存室儲存每1unit酸奶1星期的費用爲s。問要完成這個任務的最小費用是多少。 (來自http:

原创 #leetcode# Best Time to Buy and Sell Stock II

題目: Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to f

原创 動態規劃-Number String

題目: (很好懂的) Number String Time Limit: 5 Seconds      Memory Limit: 65536 KB The signature of a permutation is a string

原创 #leetcode# 223. Rectangle Area

題目: 求矩陣並。 思路: 容斥原理 代碼: class Solution { public: int a[4],b[4]; int computeArea(int A, int B, int C, int D, in

原创 #動態規劃# 子序列個數

題意 求不重複的子序列的個數 Sample Input 4 1 2 3 2 Sample Output 13 思路 dp[i] 表示考慮到第i位的 所有可能數. 1. 如果a[i] 是第一次被使用那麼,dp[i] = dp[i

原创 #leetcode# 9 Palindrome Number

題目: Determine whether an integer is a palindrome. Do this without extra space. 代碼: class Solution { public: bool

原创 BestCoder Round #75 King's Game

題目 爲了銘記歷史,國王準備在閱兵的間隙玩約瑟夫遊戲。它召來了 n(1\le n\le 5000)n(1≤n≤5000) 個士兵,逆時針圍成一個圈,依次標號 1, 2, 3 … n1,2,3…n。 第一輪第一個人從 11 開始報數,報到