#include<iostream> #include<stdio.h> #include<cstdio> using namespace std; void funct(int a , int b); int array[25]={ 2, 3, 5, 7,11,13, 17,19,23,29,31,37, 41,43,47,53,59,61, 67,71,73,79,83,89,97}; int buffer; int step; int main(int argc, char* argv[]) { int a; int b; while(cin != NULL) { cin>>a; //store the input if(a != 0) { printf("%3d! =",a); b = 0; step = 0; buffer = 0; while(a >= array[b]) { funct(a,b); b++; if(b == 25) break; } }else { break; } printf("\n"); } return 0; } void funct(int a , int b) { if(a >= array[b]) { buffer += a/array[b]; a = a/array[b]; funct(a,b); }else { step++; if(step == 16) { printf("\n "); step = 1; } printf("%3d",buffer); buffer = 0; } }
Thursday, July 29, 2010
ACM-160 Factors and Factorials with C++
ACM-113 Power of Cryptography with C
#include <stdio.h> #include <math.h> int main(int argc, char* argv[]) { double n,p; double k; while (scanf("%lf %lf", &n, &p) == 2) { k = exp(log(p)/n); printf("%.0lf\n", k); } return 0; }
Wednesday, July 21, 2010
ACM-102 Ecological Bin Packing with C++
#include<iostream> #include<stdio.h> #include<cstdio> using namespace std; string funct(int c1 , int c2 , int c3 , string s_temp , int temp , int temp_max); /********************************/ /* glass[a][b] */ /* a is bucket number */ /* b is glass color */ /* b = 1 Brown */ /* b = 2 Green */ /* b = 3 Clean */ /********************************/ int main(int argc, char* argv[]) { unsigned int Bucket[3][3]; int can_1, can_2, can_3; while (scanf("%d %d %d %d %d %d %d %d %d", &Bucket[0][0], &Bucket[0][1], &Bucket[0][2], &Bucket[1][0], &Bucket[1][1], &Bucket[1][2], &Bucket[2][0], &Bucket[2][1], &Bucket[2][2]) != EOF) { /* initiate */ unsigned int max = 0 , move = 0; int init = 0, total = 0, temp_total = 0; string s_goal = "XXX"; for(int i=0 ; i<3 ; i++) { for(int j=0 ; j<3 ; j++) { total = total + Bucket[i][j]; } } for(can_1=0 ; can_1<3 ; can_1++) { init = Bucket[0][can_1]; temp_total = Bucket[0][can_1]; for(can_2=0 ; can_2<3 ; can_2++) { if(can_1 != can_2) { temp_total = temp_total + Bucket[1][can_2]; for(can_3=0 ; can_3<3 ; can_3++) { if( (can_3 != can_2) && (can_3 != can_1) ) { temp_total = temp_total + Bucket[2][can_3]; if(temp_total >= max) { s_goal = funct(can_1 , can_2 , can_3 , s_goal , temp_total , max); max = temp_total; } temp_total = init; } } } } } move = total - max; cout<< s_goal << " " << move <<endl; } return 0; } string funct(int c1 , int c2 , int c3 , string s_temp , int temp , int temp_max) { string str=""; int size = 0; if(c1==0){ str=str+"B"; }else if(c1==1){ str=str+"G"; }else str=str+"C"; if(c2==0){ str=str+"B"; }else if(c2==1){ str=str+"G"; }else str=str+"C"; if(c3==0){ str=str+"B"; }else if(c3==1){ str=str+"G"; }else str=str+"C"; if(temp == temp_max) { while(size < 2) { if(str[size] < s_temp[size]) return str; else if(str[size] > s_temp[size]) break; else size++; } return s_temp; } return str; }
Monday, July 19, 2010
ACM-101 The Blocks Problem with C++
經過了3天的激戰
順利的擊敗了ACM-101
執行時間0.020 排名2901
神人好多阿
順利的擊敗了ACM-101
執行時間0.020 排名2901
神人好多阿
#include <sstream> #include <iostream> #include <stdio.h> #include <ctype.h> #include <cstdio> #include <list> using namespace std; list <int> block[25]; // 25 stack int pos[25]; // if block 1 is in the stack and the base block is 5 then pos[1] = 5; void initiate(); void printresult(int x); void moveonto(int a , int b); void moveover(int a , int b); void pileonto(int a , int b); void pileover(int a , int b); bool checkblock(int a , int b); int main(int argc, char* argv[]) { int block_1, block_2; int final; string str1, str2; string quit = "quit"; string move = "move"; string pile = "pile"; string onto = "onto"; string over = "over"; while( cin>>str1 ) { if(str1 == quit)//print the final result { printresult(final); }else if(str1 == move || str1 == pile) // move and pile action { cin >> block_1 >> str2 >> block_2; if(block_1 != block_2 && checkblock(block_1 , block_2)) { if(str1 == move) { if(str2 == onto) { moveonto(block_1 , block_2); }else { moveover(block_1 , block_2); } }else { if(str2 == onto) { pileonto(block_1 , block_2); }else { pileover(block_1 , block_2); } } }else { //cout<<"Are you kidding"<<endl; } }else // how many blocks are used in the process { istringstream stream1; stream1.str(str1); stream1 >> final; initiate(); } } return 0; } void initiate() { for(int i=0 ; i<25 ; i++) { if(block[i].empty()) { block[i].push_back(i); pos[i] = i; }else { block[i].clear(); block[i].push_back(i); pos[i] = i; } } } void printresult(int x) { list<int>::iterator iter2; for(int y=0 ; y<x ; y++) { iter2 = block[y].begin(); cout << y <<":"; while( iter2 != block[y].end() ) { cout <<" "<<*iter2; ++iter2; } cout<<endl; } } bool checkblock(int a , int b) { if(pos[a] != pos[b]) return true; else return false; } void moveonto(int a , int b) { int temp_pos1, temp_pos2; //use to present the target block's position; //if the target block is "3" and the stack is "1 2 3" ; then temp_pos = 1 int bpos1, bpos2; //use to present the last block in the stack; //if the stack is "1 2 3" then bpos = 3 /*** put the block back ***/ temp_pos1 = pos[a]; //where is the block a bpos1 = block[temp_pos1].back(); //the last block in the stack a temp_pos2 = pos[b]; //where is the block b bpos2 = block[temp_pos2].back(); //the last block in the stack b while(bpos1 != a) //put the last block back { block[bpos1].push_back(bpos1); pos[bpos1] = bpos1; block[temp_pos1].pop_back(); bpos1 = block[temp_pos1].back(); } while(bpos2 != b) //put the last block back { block[bpos2].push_back(bpos2); pos[bpos2] = bpos2; block[temp_pos2].pop_back(); bpos2 = block[temp_pos2].back(); } /*** move the first block onto the second block ***/ block[temp_pos1].pop_back(); block[temp_pos2].push_back(a); pos[a] = temp_pos2; } void moveover(int a , int b) { int temp_pos1, temp_pos2; //use to present the target block's position; //if the target block is "3" and the stack is "1 2 3" ; then temp_pos = 1 int bpos1; //use to present the last block in the stack; //if the stack is "1 2 3" then bpos = 3 /*** put the block back ***/ temp_pos1 = pos[a]; //where is the block a bpos1 = block[temp_pos1].back(); //the last block in the stack a temp_pos2 = pos[b]; //where is the block b while(bpos1 != a) //put the last block back { block[bpos1].push_back(bpos1); pos[bpos1] = bpos1; block[temp_pos1].pop_back(); bpos1 = block[temp_pos1].back(); } /*** move the first block onto the second block ***/ block[temp_pos1].pop_back(); block[temp_pos2].push_back(a); pos[a] = temp_pos2; } void pileonto(int a , int b) { int temp_pos1, temp_pos2; //use to present the target block's position; //if the target block is "3" and the stack is "1 2 3" ; then temp_pos = 1 int bpos2; //use to present the last block in the stack; //if the stack is "1 2 3" then bpos = 3 list<int> mylist; list<int>::iterator it; /*** put the block back ***/ temp_pos1 = pos[a]; //where is the block a //bpos1 = block[temp_pos1].back(); //the last block in the stack a temp_pos2 = pos[b]; //where is the block b bpos2 = block[temp_pos2].back(); //the last block in the stack b for(it=block[temp_pos1].begin() ; it!=block[temp_pos1].end() ; it++) { if(*it == a) { mylist.splice ( mylist.begin(), block[temp_pos1], it, block[temp_pos1].end()); break; } } while(bpos2 != b) //put the last block back { block[bpos2].push_back(bpos2); pos[bpos2] = bpos2; block[temp_pos2].pop_back(); bpos2 = block[temp_pos2].back(); //cout<<"*"; } block[temp_pos2].splice(block[temp_pos2].end(),mylist); for(it=block[temp_pos2].begin() ; it!=block[temp_pos2].end() ; it++) { pos[*it] = temp_pos2; } pos[a] = temp_pos2; } void pileover(int a , int b) { int temp_pos1, temp_pos2; //use to present the target block's position; //if the target block is "3" and the stack is "1 2 3" ; then temp_pos = 1 //int bpos1, bpos2; //use to present the last block in the stack; //if the stack is "1 2 3" then bpos = 3 list<int> mylist; list<int>::iterator it; /*** put the block back ***/ temp_pos1 = pos[a]; //where is the block a //bpos1 = block[temp_pos1].back(); //the last block in the stack a temp_pos2 = pos[b]; //where is the block b //bpos2 = block[temp_pos2].back(); //the last block in the stack b for(it=block[temp_pos1].begin() ; it!=block[temp_pos1].end() ; it++) { if(*it == a) { mylist.splice ( mylist.begin(), block[temp_pos1], it, block[temp_pos1].end()); break; } } block[temp_pos2].splice(block[temp_pos2].end(),mylist); for(it=block[temp_pos2].begin() ; it!=block[temp_pos2].end() ; it++) { pos[*it] = temp_pos2; } pos[a] = temp_pos2; }
Saturday, July 17, 2010
ACM-100 The 3n + 1 problem with C++
#include <iostream> using namespace std; int main(int argc, char* argv[]) { int a,b; int start,end; int temp,count; int max; while(cin >> a >> b) { //cout << a << b << endl; if(a > b) { start = b; end = a; }else { start = a; end = b; } max = 0; for(int k = start; k <= end ; k++) { temp = k; count = 1; while(temp!=1) { ++count; if(temp%2 ==1) { temp = 3 * temp + 1; }else { temp = temp / 2; } } if(max < count) { max = count; } } cout >> a >> " " >> b >> " " >> max >> endl; } return 0; }
TEST
public class HelloWorld{
public static void main(String args[]){
System.out.println("Hello World!");
}
}
Saturday, September 13, 2008
核心能力 V.S. 核心價值
核心能力跟核心價值可分成企業面跟個人面
個人面:
核心能力就是
你的專業能力以及相關技能
例如建築師 的核心能力是建築設計
牙醫的核心能力是 治好我們的牙齒
而核心能力 不只有專業的這項
例如 會傾聽病人需求的牙醫
傾聽能力也會是他的核心能力
核心能力就是各種專業能力跟優勢力的聚合
例如你可能就是 對程式方面的專長
加上你自己的特質能力組成的
就是你的核心能力了
而核心價值是精神面的
以一個醫生來說
他的核心價值 也許是 賺一大筆錢 或是 照顧好每個病人
依照核心價值的不同
會走上不同的路
而核心價值是比較不會改變的
就是價值觀的根本
企業面:
像GOOGLE的核心價值 就是由兩個領導者的念頭
讓世界變得更好
就是他們的核心價值
要發展核心能力是第一步
當你有了能力
再來想 你要為世界或是你自己做些什麼
就會慢慢發展出你的核心價值
感謝少璞學長的解釋
個人面:
核心能力就是
你的專業能力以及相關技能
例如建築師 的核心能力是建築設計
牙醫的核心能力是 治好我們的牙齒
而核心能力 不只有專業的這項
例如 會傾聽病人需求的牙醫
傾聽能力也會是他的核心能力
核心能力就是各種專業能力跟優勢力的聚合
例如你可能就是 對程式方面的專長
加上你自己的特質能力組成的
就是你的核心能力了
而核心價值是精神面的
以一個醫生來說
他的核心價值 也許是 賺一大筆錢 或是 照顧好每個病人
依照核心價值的不同
會走上不同的路
而核心價值是比較不會改變的
就是價值觀的根本
企業面:
像GOOGLE的核心價值 就是由兩個領導者的念頭
讓世界變得更好
就是他們的核心價值
要發展核心能力是第一步
當你有了能力
再來想 你要為世界或是你自己做些什麼
就會慢慢發展出你的核心價值
感謝少璞學長的解釋
Subscribe to:
Posts (Atom)