現在位置: 首頁 > retry發表的所有文章
題意:輸出top n高頻出現的詞和對應詞出現的次數。注意一點,可能出現超出n個輸出的情況,當且僅當超出部分的單詞出現次數和 第n個相同。 思路:模擬。 // file name: LA6578.cpp // // author: kereo // // create time: 2014年10月15日 星期三 23時11分51秒 // //***********************************// #include<iostream> #include<cstdio> #include<cstring> #include<queue> #include<set> #include<map> #include<vector> #include<stack> #include<cmath> #inclu......
閱讀全文
  • 04月
  • 06日
綜合 ⁄ 共 327字 評論關閉
大意略。 思路:推數據。 #include <iostream> #include <cstdlib> #include <cstdio> #include <string> #include <cstring> #include <cmath> #include <vector> #include <queue> #include <stack> #include <algorithm> using namespace std; int main() { int times = 0; int n; while(scanf("%d", &n) && n >= 0) { int t = 1, ans = 0; while(t < n) { t *= 2; ans++; } printf("Case %d: %d\n", ++times, ans); } return 0; }
閱讀全文
  • 10月
  • 19日
綜合 ⁄ 共 1517字 評論關閉
Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. class Solution { public: string intToRoman(int num) { char symbol[] = {'I', 'V', 'X', 'L', 'C', 'D', 'M'}; int i = 6; int weight = 1000; string result; while (num) { const int digit = num / weight; if (digit <= 3) { result.append(digit, symbol[i]); } ......
閱讀全文
  • 08月
  • 20日
綜合 ⁄ 共 8694字 評論關閉
//初始化textfield並設置位置及大小   UITextField *text = [[UITextField alloc]initWithFrame:CGRectMake(20, 20, 130, 30)];   //設置邊框樣式,只有設置了才會顯示邊框樣式     text.borderStyle = UITextBorderStyleRoundedRect;   typedef enum {     UITextBorderStyleNone,      UITextBorderStyleLine,     UITextBorderStyleBezel,     UITextBorderStyleRoundedRect     } UITextBorderStyle;    //設置輸入框的背景顏色,此時設置為白色 如果使用了自定義的背景圖片邊框會被忽略掉      text.backgrou......
閱讀全文
  • 05月
  • 01日
綜合 ⁄ 共 765字 評論關閉
      題意:  給出A和B,一有限小數的A進位數轉換成B進位數也是有限小數的判定。       我覺得如果進位轉換做的好點的話,這種題應該不難。       解法:一個小數的A 進位可以表示為:1/(A^1)+1/(A^2)+1/(A^3).....轉換成B進位就是不斷的乘B直到為0;(1/(A^1)+1/(A^2)+1/(A^3).....)*B^m,進一步化簡,要是結果為有限小數,則B^m/(A^n)必須整除,所以A中的質因子在B中都要出現。 #include <iostream> #include <cstring> #include <cstdio> using namespace std; long long num[1000009]; long long ......
閱讀全文
  • 04月
  • 27日
綜合 ⁄ 共 1326字 評論關閉
<style name="FullScreenDialog" parent="android:style/Theme.Dialog"> <item name="android:backgroundDimAmount">0.8</item> <item name="android:backgroundDimEnabled">true</item> <item name="android:windowFrame">@null</item> <item name="android:windowFullscreen">true</item> <item name="android:windowNoTitle">true</item> <item name="android:background">@android:color/transparent</item> <......
閱讀全文
  • 04月
  • 24日
綜合 ⁄ 共 1854字 評論關閉
容斥原理是對集合的運算。 舉個例子三個集合的容斥原理: A ∪ B ∪ C   =   A +  B + C   -  A ∩ B   -   B ∩ C   -   C ∩ A   + A ∩ B ∩ C. 多個集合的容斥原理: hdu 1796  How many integers can you find Problem Description   Now you get a number N, and a M-integers set, you should find out how many integers which are small than N, that they can divided exactly by any integers in the set. For example, N=12, and M-integer set is {2,3}, so there is another set {2,3,4,6,8,9,10}, all the integers o......
閱讀全文
  • 04月
  • 17日
綜合 ⁄ 共 8065字 評論關閉
  一、進程(process) 1.默認情況下,每個application都運行在一個獨立的process中,所有的component都運行在該process中的主線程中(main線程,由於主要處理UI,所以也叫UI線程)2.可以在manifest文件中通過component的android:process屬性為當前組件指定運行的process,甚至不同application中的組件都可以運行在同一個process中,  但大多數應用,我們不應該這樣去配置,除非你確實想讓你的某些組件在單獨的process中被管理3.android系統會在資源不足的情況下kill掉某些他認為可以kill的process在為用戶正在執行的動作提供資源,......
閱讀全文
原文鏈接:http://duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Chapter-1:-The-Graphics-Pipeline.html OpenGL has been around a long time, and from reading all the accumulated layers of documentation out there on the Internet, it's not always clear what parts are historic and what parts are still useful and supported on modern graphics hardware. It's about time for a new OpenGL introduction that walks through the parts that are still relevant today. Update: Join the Reddit discussi......
閱讀全文
  • 02月
  • 13日
綜合 ⁄ 共 1188字 評論關閉
1.獲得請求路徑的URL,例如URL為: http://127.0.0.1:8080/struts2/test/path1/path2/path3/test.action 2.首先尋找namespace為/path1/path2/path3的package, 如果存在這個package,則在這個package中尋找名字為test的Action, 若找到了該Action,則訪問該Action, 若沒有找到該Action則立即轉向默認表空間[namespase=""]去尋找該Action 若在默認表空間中找到了該Action,則執行該Action 若在默認表空間中沒有找到該Action,則執行該表空間中定義的默認action 若默認表空間中定義......
閱讀全文
  • 02月
  • 06日
綜合 ⁄ 共 15415字 評論關閉
delphi Midas SQLServer的自增欄位的處理 1.新增時,表中有自增欄位,但是不希望用Refresh,直接ApplyUpdates直接看見自增欄位的值在DataSetProvider.AfterUpdateRecord寫如下代碼 DataSetProvider.Options.poPropogateChanges:=True; procedure TForm1.DataSetProvider1AfterUpdateRecord(Sender: TObject;   SourceDS: TDataSet; DeltaDS: TCustomClientDataSet;   UpdateKind: TUpdateKind); begin//DstId TADODataset //FId 為自增欄位  if   UpdateKind=ukInsert then   begin   DstId.CommandText:='select  @@Identity as F......
閱讀全文
  • 01月
  • 29日
綜合 ⁄ 共 385字 評論關閉
在android裡面使用自定義字體 Typeface lcdFont = Typeface.createFromAsset(getAssets(), "fonts/lcd2mono.ttf"); txtMineCount.setTypeface(lcdFont); txtTimer.setTypeface(lcdFont); 在assets底下新建目錄fonts,然後將字體文件拷進即可 txtMineCount和txtTimer都是textview型的控制項   在視圖的onsizechanged里獲取視圖寬度,一般情況下默認寬度是320,所以計算一個縮放比率rate = (float) w/320   (w是實際寬度) 然後在設置字體尺寸時 paint.setTextSize((int)(8*rate));   (8是在解析度寬為320 下需要設置的字......
閱讀全文