I Do Believe

疲惫了一天地忙碌,到家倒头就睡。。。醒过来已经4点了。。。

2006,暑期结束了。

  • 关于Training

由于fish要去做央邦ccna的讲师,沾光,蹭了2节课玩。算是给自己的ccna打前哨探探情的,央邦没有想像中的大,不过还算是不错,主要设备挺齐全的,可以随意实验。可惜fish只是做了640-801课程osi和standard什么的介绍,后面的课是一个感觉不怎么样的gay上,这样就顺理成章的结束了短暂的ccna刺探之旅。有幸把fish的copy回来了,哈哈,几张cisco ccna的自学教程,很不错的样子,据fish说ccna绝对可以自学考。嗯,向这方面努力ing。小插曲,第一次从漕宝路下站,迷茫的在车站里飘游,虽说光大是漕宝很大的出口,居然让我飘到展览区去了。。。狂汗|||。。。貌似每次从不认识的地铁站下站都会有这样的情形,就连认识的也会。。。

  • 关于展会

除去了刚开始MoCA的Italy Made In Art, Now,这个暑期的展览确实可以用琳琅满目来形容。可惜这个××热的鬼天气,加上project的进度,也就没什么时间的说。说说最近赶的上海oracle高峰会,一般这种会也是找不到什么人陪我去了,哎~~~一样单刀赴会。这次会的主题差不多是grid computing和soa,可惜了,主要接触oracle的产品只是那个database,纯粹当是充电吧,努力努力学习。5小时左右的演讲还是让我这个外行收获颇丰,很很充实的样子,极其满足。期间很是钦佩那个貌似兼职的翻译,虽说有点上了年纪,不过对oracle的产品什么的确实真的弄得很清楚,看来功课做的很充足,不过说是翻译的水平就不怎么样了。说到这里,看到大家都在什么高口、G、ielts的,我的en也要努力了。。。

顺便tip一下9月展会计划,17日-20日的cebit asia和23日-24日的sun科技日。

  • 关于实习

说是实习,倒不如说只是一个项目的ui简单包装和database。第一天到宝信报到,然后就是作team,分到了2个复旦软院大三的家伙,很是不削他们的傲气(没有以偏概全的意思哦|||),总喜欢拿数构什么的纯理论的东西来怎么怎么的标榜自己。领project的时候也就随便他们怎么着了,反正我兵来将挡就是了,拿到的是一个设计院的员工资料登记的project。分析这个project的时候,我的感觉他们完全就是在推委,什么“数据库最简单给你了”啦,“ui没什么挑战性”的话,就当他们××了。我的分析,像这类员工登记什么的,主要可以做的工作纯粹就是在database上,优秀的检索就是在挑战有限硬件资源的最大化利用。我就不知道他们在逻辑层上除了加密外还有什么好做的,这些全是现成的。。。倒是在家soho不错,每周五去趟完成接口的连接,返回的确定。到最后我完成我份内的,他们居然能还讨论加密算法的细节。。。无奈,真不知道真的需要那么严谨的security吗。。。郁闷。等旅游回来,整体整合还是我做的。。。真不知道他们在做些什么。。。

现在就等去焦那里拿张实习的表格了,自己懒得写东西。应该25号可以拿到吧,好像说是帮我弄好的了,哈哈

  • 关于TC

现在对于algorithm的热情也没有以前那么狂热了,topcoder上面的match也是很长段时间没有去观望过。2006 tccc是没有兴趣去玩了。一次又是兴起,一清早起床做了srm 315的registration,然后又躺下了,忘了个精光,到想起来要open题的时候已经是半夜三更了。。。而后开题point 250的是骰子的题目,算点的,很是easy;point500的题更是比250还简单,居然就是算个数和,如果过2位再算和。。。point900题有点约瑟夫环的意思,可惜数构的方法怎么都想不起来,google了下,snap it,不过感觉做的有点慢了,分应该不是很高。最后rate是2500+,还是挺满意的。不过就是半夜三更的做题人有点累。。。

无意发现多了个marathon match可能这个会挺适合我吧,有时间也想试试software development,哈哈。

  • 关于看书

一直在帮侯弄新模电书的illustration,正好全当是复习模电了,貌似调制里新增加进了数字键控psk等很多通信原理里的东西,这样看来我们好像算是挺幸运的,至少学的东西比以后的要少。恰好和侯讨论用什么做illustration的时候,她说是matlab很不错,然后教了点简单的图形描绘的命令给我,加上以前一直断断续续的自学,matlab制图应该是没什么问题了,因为制图的问题,mathcad也差不多会了。不过最后的结论是用flash做函数图形,visio做电路,ai做简单图形。

应该说是书非借不能读的,这次因为据说延长可以还新校区的书,so。。。猛借了三大本砖头出来。通信系统仿真由于主要是自学matlab用的,既然会的差不多了也就扔一旁了。数字通信翻了翻也没什么看,好像是通信原理里数字部分的延伸,还是有时间要仔细看看的。现代通信系统确实是看得挺认真的,受益菲浅,就是讨厌那些一堆堆的公式计算。。。计划外开始重温2年前看的think in java,不过这次看的是3rd的。加入了些新的和dotnet的思想,很是不错。在新的ubuntu下玩eclipse做ex也很爽^_^

  • 关于旅游

嵊泗的计划由于project而耽搁,没有成行,还好,吃到了可爱的会吃肉的老虎鱼,算是补偿吧,嘻嘻

和abomer去了以俊秀名闻天下的黄山,又是可惜,天公不做美,一下索道就开始下暴雨,2天的行程就成了雾中境。。。迷漫的雾气虽说看不到了黄山远景的险峻,倒是恰好给了我们观赏松石的秀美,雾中境极其有意境,稀饭哈。旅途中也遇到了许多有趣的人,火车同座对面的舞蹈老师,看上去非常之年轻,居然30又3了。。。确老孩子气的,很是kawayi。同行的3位貌似同年龄的姐姐,一个是极会“拉人”的中尉,一个是貌似刚毕业的高中老师,还有个更巧,老强调低调的巴士学院未来的地铁调度。前面2位好像有着说不尽的话,叽叽喳喳叽叽喳喳。后面那位可以在火车上连说上上百次的要低调。。。哈。。。接下来2个精力可谓旺盛的小弟弟和小妹妹,他们的无限能量可以使我这个做哥哥也望尘莫及的。。。哎~~~人不得不服老啊。。。有时间还真想再和他们一起出去玩哈p-)

  • 关于其他

其实本来是不太看电视的,更就不用说什么“我型我show”等选秀。倒是妈妈居然乐此不疲,也就百无聊赖的有意无意瞄上几眼。发现个问题,现在越来越莫名那些电视选秀节目为什么都喜欢来cry,台上cry,台下cry,弄得我妈也来cry,猛拿纸巾擦眼睛的。。。我也不知道用观众眼泪来换取收视率有那么容易吗。。。

好像近期居委都在搞什么换届选举的,推脱间,开始想起自己许多次的投票都习惯性的弃权。。。

发现小电脑市场的混乱,一个代理的垄断,导致的价格虚高。如果买东西的话,建议上海还是奔徐家汇实在。

开始觉得游戏真的没什么吸引力了对我。

据说joi要出新专辑了,哈期待啊,嘻嘻^_^

 

这个暑假出了好多的可惜的事,不过现在的我也开始学着接受不完美的东西了,如果万事都太完美没有任何意外的话这个世界也就太无趣了

我的大三要开始了,看来自己的时间也不多了,继续努力ing…

I do believe tomorrow will be a wonderful day.

郁闷中。。。

郁闷,今天爆郁闷,昨晚等了半天好容易等到0点,TopCoder 2005 Algorithm Competition,被分到了Set 9,第一道Point 250 的题还是挺简单的,用了10多分钟,还有道Point 750 的,想想起来再做吧,就睡了。

起来看看竟然expired 了,问了才知道,计时是从open 第一道题开始的,一共60分钟要做2道题,我睡了一觉,早超时了,55555555,可怜。。。

只怪我自己不知道比赛规则,也没去仔细看,哎~~~悲惨啊

郁闷中。。。

不过想想这次认识了清华、浙大的2位高手,人家实力就是强,我也要努力了。

机会还多的是,哈哈。

中午无聊!!!无聊!!!

上午一大早起来载了《七剑》,刚看完,感觉也不怎么样,现在很少碰到有感觉的片子了,看来我还是喜欢比较感人的片子,听歌也只听写比较抒情的、Blues的,品味如就。说到歌,蔡淳佳又发新专辑了,听了听,感觉不错,从第一张专辑到现在风格还是一样。
  无聊,开了MSN(一般只开Popo用MSN插件,看不到Space的更新)看了看朋友的Space,看来大家暑期的活动还是挺丰富的。我还是比较懒,同学的聚会由于天气炎热没去,看看外面,火火的太阳,马上又要红色预警信号了吧,哎~~~这鬼天,怎么不像军训时候一样也来个什么什么的台风,刮一刮,爽一下。
  昨天参加了TopCoder(R) Single Round Match 258 做了Point 250 和Point 1000 的题目,Point 500 的看了半天没看懂,大概讲的是AutoLoan 奥的公司汽车贷款利息计算方面的问题,时间也不够,如果是像高中时候的都是中文的应该没什么问题的。MD,Point 250 的到是过了System Test,主要是Point 1000 的题,竟然给别人给Challenge Successfully了,差点气的吐血,看来还是得好好努力啊,期待16号中午开始的TCO Algorithm Competition 希望有好的成绩,对了要查查时间东部时间Noon是什么时候,北京时间好像是半夜三更哦,我晕。。。
  查到了,死了,是17号0:00 。。。不管了,努力,努力!!!

背景音乐:马郁 下辈子如果我还记得你

TopCoder(R) Single Round Match 258

Problem Statement for ClassScores

Problem Statement

    

A teacher has just finished grading the test papers for his class. To get an idea of how difficult the test was, he would now like to determine the most common score on the test. In statistics, this is called the "mode" of a set of data points. For instance, if the scores were {65, 70, 88, 70}, then the mode would be 70, since it appears twice while all others appear once.

Sometimes, in the case of a tie, the mode will be more than one number. For instance, if the scores were {88, 70, 65, 70, 88}, then the mode would be {70, 88}, since they both appear most frequently.

You are given a int[] scores. You are to return a int[] representing the mode of the set of scores. In the case of more than one number, they should be returned in increasing order.

 

Definition

    
Class: ClassScores
Method: findMode
Parameters: int[]
Returns: int[]
Method signature: int[] findMode(int[] scores)
(be sure your method is public)
    
 
 

Constraints

scores will contain between 1 and 50 elements, inclusive.
Each element of scores will be between 0 and 100, inclusive.
 

Examples

0)  
    
The first example from the problem statement.
1)  
    
The second example from the problem statement.
2)  
    
With no duplicates, all of the elements are the most frequent (appearing once each).

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2005, TopCoder, Inc. All rights reserved.

 


 

 

public class ClassScores {

public int[] findMode(int[] scores) {
  
int[] count = new int[101];
  
for (int i = 0; i < scores.length; i++)
    count[scores[i]]
++;
  
for (int i = scores.length; i ≥ 1; i{
    
int c = 0;
    
for (int j = 0; j ≤ 100; j++)
      
if (count[j] == i)
        c
++;
    
if (c > 0{
      
int p = 0;
      
int[] ret = new int[c];
      
for (int j = 0; j ≤ 100; j++)
        
if (count[j] == i) {
          ret[p] 
= j;
          p
++;
        }

      
return ret;
    }

  }

  
return new int[0];
}


}


 


 

 

Problem Statement for AutoLoan

Problem Statement

    

Auto dealerships frequently advertise tempting loan offers in order to make it easier for people to afford the "car of their dreams". A typical sales tactic is to show you various cars, and then talk in terms of what your monthly payment would be, to say nothing of how much you are actually paying for the car, how much interest you pay, or how long you have to make payments.

A typical auto loan is calculated using a fixed interest rate, and is set up so that you make the same monthly payment for a set period of time in order to fully pay off the balance. The balance of your loan starts out as the sticker price of the car. Each month, the monthly interest is added to your balance, and the amount of your payment is subtracted from your balance. (The payment is subtracted after the interest is added.) The monthly interest rate is 1/12 of the yearly interest rate. Thus, if your annual percentage rate is 12%, then 1% of the remaining balance would be charged as interest each month.

You have been checking out some of the cars at your local dealership, TopAuto. An excited salesman has just approached you, shouting about how you can have the car you are looking at for a payment of only monthlyPayment for only loanTerm months! You are to return a double indicating the annual percentage rate of the loan, assuming that the initial balance of the loan is price.

 

Definition

    
Class: AutoLoan
Method: interestRate
Parameters: double, double, int
Returns: double
Method signature: double interestRate(double price, double monthlyPayment, int loanTerm)
(be sure your method is public)
    
 
 

Notes

Because of the way interest is compounded monthly, the actual interest accrued over the course of a year is not necessarily the same as (balance * yearly interest rate). In fact, it's usually more.
In a real situation, information like this would typically need to be disclosed, but since you aren't at a point of signing any paperwork, the salesman has no legal obligation to tell you anything.
The return value must be within 1e-9 absolute or relative error of the actual result.
 

Constraints

price will be between 1 and 1000000, inclusive.
monthlyPayment will be between 0 and price / 2, inclusive.
loanTerm will be between 1 and 600, inclusive.
The resulting interest rate will be between 0 and 100, inclusive.
 

Examples

0)  
    
Noting that 68 payments of 100 equals the total price of 6800, so there is no interest.
1)  
    
Here, we do pay a little interest. At 9.562% annual interest, that means each month we pay 0.7968% of the balance in interest. Our payment schedule looks like this:
2)  
    
This is similar to what purchasing a new car with no money down might look like, if you make payments for 4 years.

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2005, TopCoder, Inc. All rights reserved.

 


 

 

public class AutoLoan {

private double amort(double principal, double payment, int term, double interest) {
  
double m = interest / 1200;
  
if (principal * m > payment)
    
return 1;
  
for (int i = 0; i < term; i++)
    principal 
= principal * (1 + m)  payment;
  
return principal;
}


public double interestRate(double price, double monthlyPayment, int loanTerm) {
double ret = 0;
double inc = 1000000000;
while (inc ≥ 1.0E-18{
  
double d = amort(price, monthlyPayment, loanTerm, ret + inc);
  
if (d ≤ 0{
    ret 
+= inc;
  }

  inc 
/= 2.0;
}


return ret;

}


}


 


Problem Statement for MissileTarget

Problem Statement

    

You are working for a defense agency that is testing the accuracy of a new missile guidance system. As part of this effort, several missiles have been fired off. Each missile fired was programmed with the same target coordinates, although the actual points of impact vary.

Your task is to determine the "best fit" point to describe the location where the missiles actually landed. To determine how well a point describes the location, calculate the cartesian distance from the point to each of the landing points. Then, total the sum of the squares of these distances. The best fit point is the point that minimizes this sum.

You are given int[]s x and y, both containing the same number of elements, where the i-th element of x and the i-th element of y describe the coordinates of the i-th missile landing point. You are to return a int[] with exactly two elements, describing the coordinates of the lattice point (point with integral coordinates) that is closest to the "best fit" point. The first element should be the x-coordinate, and the second element should be the y-coordinate.

 

Definition

    
Class: MissileTarget
Method: bestFit
Parameters: int[], int[]
Returns: int[]
Method signature: int[] bestFit(int[] x, int[] y)
(be sure your method is public)
    
 
 

Notes

The cartesian distance between two points (x1, y1) and (x2, y2) is defined as Sqrt((x2-x1)^2 + (y2-y1)^2).
The return value must be within 1e-9 absolute or relative error of the actual result.
 

Constraints

x will contain between 1 and 50 elements, inclusive.
x and y will contain the same number of elements.
Each element of x will be between -1000000 and 1000000, inclusive.
Each element of y will be between -1000000 and 1000000, inclusive.
The actual (possibly non-lattice) best fit point will be at least 1e-2 closer to the correct return value than to any other lattice point.
 

Examples

0)  
    
These three impacts are all pretty close to the origin, and sure enough, the origin is the best fit point.
1)  
    
With only one point, it is its own best fit.
2)  
    
With only two points, the best fit is the midpoint between the two.
3)  
    
 
4)  
    
In this case, notice that the actual best fit point possible is (5.333, 0). If we look at lattice points only, then our best fit is (6, 0), however, we are interested in the lattice point that is closest to the actual best fit point, so we return (5, 0).

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2005, TopCoder, Inc. All rights reserved.


 

This is another problem that is fairly easily solved with a bit of grunt work to calculate out the desired values. Since we are looking for the lattice point that is closest to our best fit, our best bet is to first calculate the location of the actual best fit point (using floating point, that is), and then find the closest lattice point.

To find the best fit point, we one important observation: calculating the best fit x-coordinate and the best fit y-coordinate separately will give us our best fit point. Why? Since the scoring of a point as being best fit is based upon the sum of the squares of the distances from each of the points, we see that:

score = sum(d^2) = sum(sqrt((xx0)^2 – (yy0)^2)^2)
  = sum((xx0)^2 + (yy0)^2)
  = sum((xx0)^2) + sum((yy0)^2)

So, to minimize the score, it suffices to minimize each sum separately.

To minimize each sum, a ternary search works well. However, in this case, if you were inclined to do the mathematical gruntwork, then you found a nice shortcut. The average of the x-coordinates will give you the x-coordinate of the best fit point, and the same goes for the y-coordinates. (Why? Hint: Use calculus to prove where the minimum value is.)

Either way, once you have the location of the best fit point it's just simply a matter of finding the closest lattice point, and the easiest way to do this is by rounding. (Note the constraints were intended to prohibit the case where a point was equidistant from multiple lattice points.)

TopCoder(R) Single Round Match 257

本来想试试昨天的TopCoder(R) Single Round 的的,起得太晚了,没赶上Registration ,哎~~~可惜。。。
贴上题目做做吧
 


 

SubstitutionCode  Point 250
 Division Two – Level One

 

Problem Statement for SubstitutionCode

Problem Statement

     A simple, easy to remember system for encoding integer amounts can be very useful. For example, dealers at flea markets put the information about an item on a card that they let potential buyers see. They find it advantageous to encode the amount they originally paid for the item on the card.

A good system is to use a substitution code, in which each digit is encoded by a letter. An easy to remember 10-letter word or phrase, the key, is chosen. Every '1' in the value is replaced by the first letter of the key, every '2' is replaced by the second letter of the key, and so on. Every '0' is replaced by the last letter of the key. Letters that do not appear in the key can be inserted anywhere without affecting the value represented by the code.. This helps to make the resulting code much harder to break (without knowing the key).

Create a class SubstitutionCode that contains the method getValue that is given the Strings key and code as input and that returns the decoded value.

 

Definition

    
Class: SubstitutionCode
Method: getValue
Parameters: String, String
Returns: int
Method signature: int getValue(String key, String code)
(be sure your method is public)
    
 
 

Constraints

code contains between 1 and 9 characters inclusive, all uppercase letters 'A'-'Z'
code contains at least one letter that is found in key
key contains exactly 10 uppercase letters 'A'-'Z', all distinct from each other
 

Examples

0)  
    
The L,X, and V are ignored since they do not appear in the key. G is the seventh letter in the key, W is the 10th letter, and E is the 9th letter.
1)  
    
 
2)  
    
 

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2005, TopCoder, Inc. All rights reserved.

 

 


 

BridgePts  Point 500
 Division Two – Level Two

 

Problem Statement for BridgePts

Problem Statement

     A deck of cards contains 52 cards. Each card has a suit (Clubs,Diamonds,Hearts,Spades) and a value (Ace,2,3,…,9,10,Jack,Queen,King). In the game of bridge a hand consists of 13 cards from the deck.

A player needs to evaluate his hand, giving it a point value. The standard method is as follows: count 4 points for each Ace, 3 points for each King, 2 points for each Queen, and 1 point for each Jack. For each suit, count 1 point if the hand contains exactly two cards of that suit, 2 points if exactly one card, and 3 points if the hand contains no cards of that suit. The point value of the hand is the sum of all these points.

Create a class BridgePts that contains a method pointValue that is given a int[] hand and that returns the point value of the hand.

Each element of hand indicates a card. The clubs are numbered 1 to 13, the diamonds are 14 to 26, the hearts are numbered 27 to 39, and the spades are numbered 40 to 52. Within each suit, the cards are numbered in the order Ace, 2, 3, …, 9, 10, Jack, Queen, King. So, for example, the King of Hearts is numbered 39 and the Ace of Spades is numbered 40.

 

Definition

    
Class: BridgePts
Method: pointValue
Parameters: int[]
Returns: int
Method signature: int pointValue(int[] hand)
(be sure your method is public)
    
 
 

Constraints

hand will contain exactly 13 elements, all distinct.
Each element of hand will have a value between 1 and 52 inclusive.
 

Examples

0)  
    
This hand contains all diamonds, so it has one Ace, one King, one Queeen, and one Jack, and it contains no cards in three suits. So its point value is 4 + 3 + 2 + 1 + 3 + 3 + 3 = 19.
1)  
    
This hand contains only 2's, 3's, 4's and one 5. It has 3 or 4 cards in each suit.

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2005, TopCoder, Inc. All rights reserved.

 

 


 

TimeCard  Point 1000
 Division Two – Level Three

 

Problem Statement for TimeCard

Problem Statement

     When I start my shift at work I punch in my starting time, and when I leave I punch out. The times are printed on a card using exactly 8 characters in the format where hh is the 2 digit representation of the hour, mm is the 2 digit representation of the minute, and xx is either am or pm. The ':' and ',' are literal. "12:00,am" denotes midnight, while "12:00,pm" denotes noon.

The difference between that time I punch in and the time I punch out is the amount of time I have worked so, for example, if I punch in at 03:33pm and punch out at 03:34pm I have worked 1 minute.

No shift is allowed to be more than 20 hours long. This is my last shift of the week and I am supposed to work 40 hours during the week. Create a class TimeCard that contains a method leave that is given a String[] time of all the times on this week's timecard and that returns a String (using the same format) that tells when I can leave and have exactly 40 hours for the week. Return "BELOW 40" or "ABOVE 40" if it is not possible to get exactly 40 hours. In all cases, the return should contain exactly 8 characters.

The elements of time alternate: punch in time, punch out time, punch in time, … with the final element being the time I just punched in on my final shift.

 

Definition

    
Class: TimeCard
Method: leave
Parameters: String[]
Returns: String
Method signature: String leave(String[] time)
(be sure your method is public)
    
 
 

Constraints

time will contain an odd number of elements between 1 and 49 inclusive.
Each element of time will be formatted as above.
In each element of time hh will be between 01 and 12 inclusive.
In each element of time mm will be between 00 and 59 inclusive.
time will contain no shift that exceeds 20 hours in duration.
 

Examples

0)  
    
This is my one and only shift, and I am only allowed to work 20 hours on a shift.
1)  
    
I have worked 4 previous shifts of 8 hours, so I need 8 hours on this shift to make 40.
2)  
    
I have already worked 2 shifts of 20 hours so I already have exactly 40 hours. I should go home immediately.
3)  
    
 
4)  
    
 

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2005, TopCoder, Inc. All rights reserved.

Practise – Inv 2001 R1 Point 250

Problem Statement