EragonJ – A humble navigator

About EragonJ | About this blog

Archive for the ‘ZeroJudge’ tag

[ACM] List of solved problems

2 comments

Image Credit

最後一個學期,有幸上到 Electron 電子哥第一次也是最後一次開的「程式競技」,總算是有一個目標來推動自己去寫這些題目(雖然在成功高中的時候就和電研社的朋友們寫了一些了,好懷念呀),所以想要做個統一整理,把所有解過的問題都放到 Github Repo 上面並附加註解,做個記錄。

這篇會一直持續更新,如果有興趣的人可以觀注這篇文章。

Uva

ZeroJudgeー大專院校版

PKU online Judge


Written by EragonJ

March 5th, 2011 at 1:11 pm

Posted in ACM

Tagged with , , , ,

[ZeroJudge] p001 Minesweeper

leave a comment

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

點我看題目

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

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

Written by EragonJ

February 2nd, 2010 at 2:37 pm

Posted in ACM

Tagged with , , , , ,

[ZeroJudge]p018 Polynomial coefficients

leave a comment

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

Written by EragonJ

December 4th, 2009 at 6:52 pm

Posted in ACM

Tagged with ,

[ZeroJudge] a010 因數分解

leave a comment

這題也是有點有趣 , 不過我自己的做法比較笨一點 ,
就是先開個可以容的下題目的array[1000000] , 然後
去存哪些因數有算過就++ , 最後再去總結算 !

要注意的地方:
1.我用了recursive的方法去實做
2.用search function 去找有x個格子的數字不是0 (x-1就是乘號的數目)

大概就是這樣! 如果有什麼比較好的方法請提供一下:D


#include <iostream>
#define MAX 1000000
using namespace std;
int arr[MAX]={0};
void div(int input){
int i;
int sinput = input;
for(i=2;i<=sinput;i++){
if(sinput%i==0){
arr[i]+=1;
sinput/=i;
break;
}
}
if(input!=sinput){
div(sinput);
return ;
}
}
void reset(){
int i;
for(i=0;i<MAX;i++){
arr[i]=0;
}
}
int search(){
int i,count=0;
for(i=2;i<MAX;i++){
if(arr[i]!=0) count++;
}
return count;
}
int main(){

int h,i,k,scount=0;

while(cin >> i){
div(i);
scount = search()-1;
for(k=2;k<MAX;k++){
if(arr[k]!=0){
if(arr[k]==1){
cout << k ;
}else{
cout << k << "^" << arr[k] ;
}
if(scount!=0){
cout << " * " ;
scount--;
}
}
}
cout << endl;
reset();
}
system("pause");
return 0;
}

Written by EragonJ

January 22nd, 2009 at 10:24 am

Posted in ACM

Tagged with , ,