EragonJ's World

About me

Archive for the ‘ACM’ tag

[ZeroJudge] p001 Minesweeper

without comments

最近又開始覺得很無聊,所以要回去寫題目來練習,剛好就拿ZJ2的Minesweeper來小試一下,

點我看題目

這個題目就是要實作簡單版的採地雷(概念上),所以還蠻有趣的XD。

P.S. 我發現我之前寫ACM的文章都是用code tag包起來,但是只要沒有相對應的Css來搭配就真的是什麼都顯示不出來,有夠給他難看的…我晚點再來把他們都放上gist!

Written by admin

February 2nd, 2010 at 2:37 pm

Posted in ACM

Tagged with , , , , ,

[計畫]想做的事

without comments

就在剛剛終於逃離了期末考的魔爪,現在要來列個清單是關於我整個寒假的計畫,能完成多少就多少吧。

  • 讀書計畫
    1. read 愛上jQuery & 深入淺出 Ajax
    2. [Done]read Facebook:性愛與金錢、天才與背叛交織的祕辛
    3. read Introduction to Algorithms
    4. …增加中
  • 工作計畫
    1. EatMe 主站規劃
    2. Hax4   主站規劃
    3. 畢業專題構思
    4. ACM解題
    5. …增加中
  • 其餘活動
    1. 食我出遊
    2. [Done]資轉出遊
    3. 死黨聚會
    4. ??
    5. …增加中

結論就是,等著累死吧!!!!!

Written by admin

January 18th, 2010 at 3:27 pm

Posted in Others

Tagged with , , , , , ,

[PKU]1503 Integer_Inquiry

without comments

我寫到快殺人了…

其實這題我一直都寫好了,但是就一直WA,最該死的就是我不知道問題在哪…也看了很多討論,但是就不知道錯在哪,有心的幫幫我一下吧..


PKU的測試位置(要帳號)

Written by admin

December 11th, 2009 at 1:05 pm

Posted in ACM

Tagged with , , ,

[ZeroJudge]p018 Polynomial coefficients

without comments

就是多項式係數計算的簡化版,因為X1 , X2 …. Xn 就只是個變數,不會有像
高中數學那樣,還要考慮因為次方而多產生的係數,算是蠻簡單的,只是這邊
用到Recursive的Factorial計算,他有故意限定是 (0<K,N<13),所以用
long long int 去算就可以了,沒有太多困難。

Written by admin

December 4th, 2009 at 6:52 pm

Posted in ACM

Tagged with ,

[UVa]944 Happy Numbers

without comments

要注意一下題目的換行是要在兩個output之間 , 最後一個output就不能送出 endline ..

Written by admin

November 27th, 2009 at 6:15 pm

Posted in ACM

Tagged with , ,

[ACM] 3n+1

with 2 comments

太久沒有寫code了 , 想說來寫寫練習一下 , 剛好看到有人的3n+1的code , 想說來寫個比較簡短的版本 , 直接recursive 下去做真的是方便時很多呢!

BTW , 我發現我真的很愛用三元運算子= =” , 清楚又短~


#include <stdio.h>
void cal(int,int);
int m_cal(int,int);
int main (int argc, const char * argv[]) {
int input1,input2;
while(scanf("%d%d",&input1,&input2)!=-1){
cal(input1,input2);
}
return 0;
}
int m_cal(int a,int length){
if(a==1){
return length;
}else if(a%2==1){
return m_cal(a*3+1,length+1);
}else{
return m_cal(a/2,length+1);
}
}
void cal(int a,int b){
int i=a>b?b:a,j=a>b?a:b;
int temp,memory=0;
for(i;i<=j;i++){
temp = m_cal(i,1);
memory = temp>memory ? temp:memory;
}
printf("%d %d %d\n",a,b,memory);
}

Written by admin

March 24th, 2009 at 2:36 am

Posted in ACM

Tagged with ,

[ACM]412 Pi

without comments


這題比較要注意的地方有以下幾點:

1.先把π的公式由數學式導出來
2.要用到數學的排列組合(C X取2這樣)
3.算互質的個數
4.格式化輸出(精確到小數點下第六位)

心得:在算最後一步的時候(求π時) , 要小心那個double的地方 , 因為int
在算的時候會有拾去的情況 , 最好是都用同個型態去算 , 比較不會出問題


#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int c_num(int i){
return (i*(i-1))/2;
}
void sort(int arr[],int num){
int i,j;
for(i=0;i<num-1;i++){
for(j=i+1;j<num;j++){
if(arr[i]<arr[j]){
swap(arr[i],arr[j]);
}
}
}
}
void swap(int* a,int* b){
int temp;
temp = *a;
*a = *b;
*b = temp;
}
int judge(int a,int b){
int max = (a<b)?a:b;
int min = (a<b)?a:b;
int reminder,quotient;
reminder = max%min;
quotient = max/min;
while(reminder!=0){
max = min;
min = reminder;
quotient = max/min;
reminder = max%min;
}
return min;
}
int main(){

int i,j,k;
int arr[200],count;
while(cin >> i){
count = 0;
if(i==0){
return 0;
}else{
for(j=0;j<i;j++){
cin >> arr[j];
}
sort(arr,i);
for(j=0;j<i-1;j++){
for(k=j+1;k<i;k++){
if(judge(arr[k],arr[j])==1){
count++;
}
}
}
if(count==0){
cout << "No estimate for this data set." << endl;
}else{
printf("%.6lf\n",sqrt(((double)(6*c_num(i))/count)));
}
}
}
system("pause");
return 0;
}

Written by admin

January 22nd, 2009 at 6:07 am

Posted in ACM

Tagged with , ,

[ACM] 最近在解ACM..

without comments

好久沒有解ACM了 , 我發現現在我要解一些題目 , 就感覺比較不會那麼的困擾了 …

現在是用ZeroJudge的線上解題系統來解題的 , 以後如果有解出的題目 , 除了一些

很簡單的不會放外 (像是什麼物理子彈那種= =) 其他的都會放上來一下:D

Written by admin

January 22nd, 2009 at 6:04 am

Posted in ACM

Tagged with