原创 URAL 1152 False Mirrors (DFS枚舉)

/*本來想用貪心,每次挑能打中最多的怪的地方打,後來想想不行,因爲如果有兩個位置能打中一樣多的怪,但是打中某個地方後會把剩下的怪弄得支離破碎,不好集中打*/ #include <stdio.h> #define MAX_BALCONIES

原创 Android Studio 設置內存大小及原理,優化運行速度

Android studio 1.0.2默認最大內存是750M,這樣跑起來非常的卡,難以忍受,機器又不是固態硬盤,最後發現,這個默認值是可以修改的,在android studio目錄下找到:studio64.exe.vmoptions文

原创 Handler消息處理機制

public void dispatchMessage(Message msg) { if (msg.callback != null) { //通過post(Runable r)發送消息,會把R

原创 Zygote進程啓動System Server進程的過程

Android系統啓動時,Init進程會把Zygote進程啓動起來,而Zygote進程會把System Server進程啓動起來。 App_main.cpp int main(int argc, char* const argv[]

原创 Building Your First App

This works fine for the button, but not as well for the text field, because the user might type something longer. It w

原创 URAL 1279 Warehouse

#include <stdio.h> #define MAX_HIGHT 1000 int numOfRows, numOfColumns, numOfNewContainers; int sections[MAX_HIGHT + 1]

原创 URAL 1534 Football in Gondor

#include <stdio.h> long long scoredBalls, missedBalls; long long numOfMatches; long long max, min; int main(){

原创 URAL 1354 Palindrome. Again Palindrome (迴文 + KMP)

#include <stdio.h> char string[10001]; char reverseString[10001]; int next[10001]; int main(){ scanf("%s", string);

原创 HDU 1688 Sightseeing

#include <stdio.h> #define MAX_CITIES 1000 #define MAX_ROADS 10000 #define INF 1000000 int numOfCities, numOfRoads; t

原创 URAL 1297 Palindrome (迴文+中心擴展)

#include <stdio.h> char string[1001]; int main(){ scanf("%s", string); int len = 0; int i; for (i = 0; string[i]

原创 URAL 1723 Sandro's Book

#include <stdio.h> char string[51]; int letterCount[26]; int main(){ scanf("%s\n", string); int i; for (i = 0; s

原创 URAL 1684 Jack's Last Word

#include<stdio.h> #define MAX_LONG 75001 char T[MAX_LONG << 1]; char S[MAX_LONG]; int next[MAX_LONG << 1]; int flag[M

原创 Binder進程間通信機制的Client進程和Server進程的通信過程

               Binder進程間通信機制的Client進程和Server進程的一次進程間通信過程可以分爲6個步驟。 1. Client進程想Binder驅動程序發送一個BC_TRANSACTION命令協議。 2. Bind

原创 Activity組件啓動過程

       Android系統的Activity組件負責管理Android應用程序的用戶界面。        運行在不同進程中的Activity組件通過Binder進程間通信機制來協作完成任務。        從應用程序的角度出發,Ac

原创 Android應用程序的消息處理機制

        Android應用程序是通過消息來驅動的。Android應用程序的每一個線程在啓動時,都可以首先在內部創建一個消息隊列,然後循環檢查隊列中是否有新消息要處理。如果有新消息需要處理,線程從隊列中取出消息並處理,否則線程進入睡