#include<stdio.h> #include<stdlib.h> int main(){ int c, i, j, n ; long long int farm[3] ; long long int sum ; while(scanf("%d",&c)==1){ for(i=0 ; i<c ; ++i){ sum = 0 ; scanf("%d",&n) ; for(j=0 ; j<n ; ++j){ scanf("%lld %lld %lld",&farm[0],&farm[1],&farm[2]) ; sum += farm[0]*farm[2] ; } printf("%lld\n",sum) ; } } return 0 ; }
2013年8月12日 星期一
c005. 環保獎金、UVA 10300 - Ecological Premium
c004. Beat the Spread!、uva - 10812
#include<stdio.h> #include<stdlib.h> int main(){ int c, a, b, i, sum; while(scanf("%d",&c)==1){ for(i=0 ; i<c ; ++i){ scanf("%d %d",&a,&b) ; sum = a+b ; if(a<0 || b<0 || a<b || sum%2){ puts("impossible") ; continue ; } else printf("%d %d\n",sum/2,a-sum/2) ; } } return 0 ; }
2013年8月5日 星期一
emacs 簡繁轉換 -- 使用新同文堂python
需要環境
python2.7
請上官網下載安裝,並加入系統變數裡裡
unicad.el - emacs 識別編碼用
下載並安裝unicad.el
wget "http://unicad.googlecode.com/files/unicad-1.1.4.tar.gz" tar -zxv -f unicad-1.1.4.tar.gz
在.emcac加入下面這兩行
(add-to-list 'load-path "/path/to/unicad_folder") ;這行要指定路徑 (require 'unicad)
安裝教學
git clone "https://github.com/monkey413/tongwen-emacs.git
在.emcac加入下面這兩行
(add-to-list 'load-path "/path/to/tongwen-emacs") ;這行要指定路徑 (require 'hanconvert)
使用教學
M-x hanconvert-to
2013年8月3日 星期六
d710. parking lot
#include<iostream> #include<string> using namespace std; int main(){ string db[21][2] ; string s, s1 ; int c, q, j=0; while(cin>>c>>q){ if(j++) cout << endl ; for(int i=0 ; i<c ; ++i) cin >> db[i][0] >> db[i][1] ; for(int i=0 ; i<q ; ++i){ cin >> s >> s1 ; if(s=="brand"){ for(int i=0 ; i<c ; ++i) if(db[i][0]==s1) cout << db[i][0] << " " << db[i][1] << endl ; } else{ for(int i=0 ; i<c ; ++i) if(db[i][1]==s1) cout << db[i][0] << " " << db[i][1] << endl ; } } } return 0 ; }
c002: f91、UVA 10696 - f91
#include<stdio.h> #include<stdlib.h> int main(){ int n ; while(scanf("%d",&n)==1){ if(!n) break ; if(n>100) printf("f91(%d) = %d\n",n,n-10) ; else{ printf("f91(%d) = 91\n",n); } } return 0 ; }
c001: 最長共同字串(LCS)、UVA 10405 - Longest Common Subsequence
#include<iostream> #include<cstring> #include<string> #include<algorithm> #define MAX 1001 using namespace std; int main(){ string s1, s2 ; int LCS_table[MAX][MAX] ; while(cin>>s1>>s2){ memset(LCS_table,0,sizeof(LCS_table)); for(int i=1 ; i<s1.length()+1 ; ++i){ for(int j=1 ; j<s2.length()+1 ; ++j){ if(s1[i-1] == s2[j-1]){ LCS_table[i][j] = LCS_table[i-1][j-1]+1 ; } else{ LCS_table[i][j] = max(LCS_table[i-1][j],LCS_table[i][j-1]) ; } } } cout << LCS_table[s1.length()][s2.length()] << endl ; } return 0 ; }
2013年7月13日 星期六
manage vim plugin use pathogen (ex: clang)
第一步:把clang_complete.vmb所產生出來的所有資料放入clang_complete資料夾(自己建) 第二步:下載pathogen.vim 第三步:放入~/.vim/autoload/資料夾裡面(沒有的話自己建) 第四步:建立資料夾~/.vim/bundle/ 第五步:把clang_complete資料夾放入~/.vim/bundle/裡面 第六步:在.vimrc加入這三行 execute pathogen#infect() syntax on filetype plugin indent on 參考資料:http://yuanfarn.blogspot.tw/2013/02/pathogen-vim-plugin.html
訂閱:
文章 (Atom)