
回答 4 已采纳 ```
package inheritance;
//Manager类继承了Employee类
public class Manager extends Employee{
private double bonus;
public Manager(String n, double s, int year, int month, int day){
//利用super关键词调用Employee类的构造器
super(n, s, year, month, day);
bonus = 0;
}
//覆盖了Employee类中的getSalary方法
public double getSalary(){
//用super关键字调用Employee类的方法
double baseSalary = super.getSalary();
return baseSalary + bonus;
}
public void setBonus(double b){
bonus = b;
}
}
package inheritance;
import java.util.Date;
import java.util.GregorianCalendar
public class Employee {
private String name;
private double salary;
private Date hireDay;
public Employee(String n,double s ,int year,int month,int day){
name = n;
salary = s;
GregorianCalendar calendar = new GregorianCalendar(year, month1, day); hireDay = calendar.getTime();
}
public String getName(){
return name;
}
public double getSalary(){
return salary;
}
public Date getHireDay(){
return hireDay;
}
public void raiseSalary(double byPercent){
double raise = salary * byPercent / 100;
salary += raise;
}
}
public static void main(String[] args){
//constrcut a Manager object
Manager boss = new Manager("Cracker",80000,1988,12,15); boss.setBonus(5000);
Employee[] staff = new Employee[3]; //fill the staff arry with Manager and //Employee object
staff[0] = boss;
staff[1] = new Employee("Harry",50000,1986,10,1);
staff[2] = new Employee("Tommy",40000,1987,3,15);
//print out information about all Employee objects
//体现了多态与动态捆绑
for(Employee e : staff)
System.out.println("name:" + e.getName() + "，salary:" + e.getSalary());
}
```
进行类型转换的唯一原因是：**在暂时忽视对象的实际类型之后，使用对象的全部功能。**例如，在Manager类中，由于某些项是普通雇员，所以staff数组必须是Employee对象的数组。我们需要将数组中引用经理的元**素复原成Manager类，**以便能够访问新增加的所有变量（需要注意，在前面的代码中，为了避免类型转换，我们做了**一些特别的处理**，即将boss变量存入数组之前，先用Manager对象对它进行初始化。为了设置经理的奖金，必须使用正确的类型）

1.什么叫暂时忽视对象的类型，使用对象的全部功能？

2.什么叫复原成Manager类，以便能够访问新增加的所有变量？这些新增加的变量是啥，能否指出来？

3.上段话还提出了做出了特别的处理，完全搞不懂在哪儿？

回答 1 已采纳 Professor Robert A. J. Matthews of the Applied Mathematics and Computer Science Department at the University of Aston in Birmingham, England has recently described how the positions of stars across the night sky may be used to deduce a surprisingly accurate value of Pi. This result followed from the application of certain theorems in number theory.
Here, we don't have the night sky, but can use the same theoretical basis to form an estimate for Pi:
Given any pair of whole numbers chosen from a large, random collection of numbers, the probability that the two numbers have no common factor other than one (1) is 6/Pi^2
For example, using the small collection of numbers: 2, 3, 4, 5, 6; there are 10 pairs that can be formed: (2,3), (2,4), etc. Six of the 10 pairs: (2,3), (2,5), (3,4), (3,5), (4,5) and (5,6) have no common factor other than one. Using the ratio of the counts as the probability we have:
6/Pi^2 = 6/10
Pi = 3.162
In this problem, you'll receive a series of data sets. Each data set contains a set of pseudorandom positive integers. For each data set, find the portion of the pairs which may be formed that have no common factor other than one (1), and use the method illustrated above to obtain an estimate for Pi. Report this estimate for each data set.
Input
The input consists of a series of data sets.
The first line of each data set contains a positive integer value, N, greater than one (1) and less than 50.
There is one positive integer per line for the next N lines that constitute the set for which the pairs are to be examined. These integers are each greater than 0 and less than 32768.
Each integer of the input stream has its first digit as the first character on the input line.
The set size designator, N, will be zero to indicate the end of data.
Output
A line with a single real value is to be emitted for each input data set encountered. This value is the estimate for Pi for the data set. An output format like the sample below should be used. Answers must be rounded to six digits after the decimal point.
For some data sets, it may be impossible to estimate a value for Pi. This occurs when there are no pairs without common factors. In these cases, emit the singleline message:
No estimate for this data set.
exactly, starting with the first character, "N", as the first character on the line.
Sample Input
5
2
3
4
5
6
2
13
39
0
Sample Output
3.162278
No estimate for this data set.

回答 2 已采纳 Description
To enable homebuyers to estimate the cost of flood insurance, a realestate firm provides clients with the elevation of each 10meter by 10meter square of land in regions where homes may be purchased. Water from rain, melting snow, and burst water mains will collect first in those squares with the lowest elevations, since water from squares of higher elevation will run downhill. For simplicity, we also assume that storm sewers enable water from highelevation squares in valleys (completely enclosed by still higher elevation squares) to drain to lower elevation squares, and that water will not be absorbed by the land.
From weather data archives, we know the typical volume of water that collects in a region. As prospective homebuyers, we wish to know the elevation of the water after it has collected in lowlying squares, and also the percentage of the region's area that is completely submerged (that is, the percentage of 10meter squares whose elevation is strictly less than the water level). You are to write the program that provides these results.
Input
The input consists of a sequence of region descriptions. Each begins with a pair of integers, m and n, each less than 30, giving the dimensions of the rectangular region in 10meter units. Immediately following are m lines of n integers giving the elevations of the squares in rowmajor order. Elevations are given in meters, with positive and negative numbers representing elevations above and below sea level, respectively. The final value in each region description is an integer that indicates the number of cubic meters of water that will collect in the region. A pair of zeroes follows the description of the last region.
Output
For each region, display the region number (1, 2, ...), the water level (in meters above or below sea level) and the percentage of the region's area under water, each on a separate line. The water level and percentage of the region's area under water are to be displayed accurate to two fractional digits. Follow the output for each region with a blank line.
Sample Input
3 3
25 37 45
51 12 34
94 83 27
10000
0 0
Sample Output
Region 1
Water level is 46.67 meters.
66.67 percent of the region is under water.

回答 1 已采纳 Problem Description
Dr. Grey is a data analyst, who visualizes various aspects of data received from all over the world everyday. He is extremely good at sophisticated visualization tools, but yet his favorite is a simple selfmade histogram generator.
![](http://acm.hdu.edu.cn/data/images/C38410001.jpg)
Figure 1: A histogram
Figure 1 is an example of histogram automatically produced by his histogram generator. A histogram is a visual display of frequencies of value occurrences as bars. In this example, values in the interval 0–9 occur five times, those in the interval 10–19 occur three times, and 20–29 and 30–39 once each. Dr. Grey’s histogram generator is a simple tool. First, the height of the histogram is fixed, that is, the height of the highest bar is always the same and those of the others are automatically adjusted proportionately. Second, the widths of bars are also fixed. It can only produce a histogram of uniform intervals, that is, each interval of a histogram should have the same width (10 in the above example). Finally, the bar for each interval is painted in a grey color, where the colors of the leftmost and the rightmost intervals are black and white, respectively, and the darkness of bars monotonically decreases at the same rate from left to right. For instance, in Figure 1, the darkness levels of the four bars are 1, 2/3, 1/3, and 0, respectively. In this problem, you are requested to estimate ink consumption when printing a histogram on paper. The amount of ink necessary to draw a bar is proportional to both its area and darkness.
Input
The input consists of multiple datasets, each of which contains integers and specifies a value table and intervals for the histogram generator, in the following format:
nw
v1
v2
.
.
.
vn
n is the total number of value occurrences for the histogram, and each of the n lines following the first line contains a single value. Note that the same value may possibly occur multiple times. w is the interval width. A value v is in the first (i.e. leftmost) interval if 0 ≤ v<w, the second one if w ≤ v< 2w, and so on. Note that the interval from 0 (inclusive) to w (exclusive) should be regarded as the leftmost even if no values occur in this interval. The last (i.e. rightmost) interval is the one that includes the largest value in the dataset.
You may assume the following:
1 ≤ n ≤ 100
10 ≤ w ≤ 50
0 ≤ vi ≤ 100
for 1 ≤ i ≤ n
You can also assume that the maximum value is no less than w. This means that the histogram has more than one interval. The end of the input is indicated by a line containing two zeros.
Output
For each dataset, output a line containing the amount of ink consumed in printing the histogram. One unit of ink is necessary to paint one highest bar black. Assume that 0.01 units of ink per histogram is consumed for various purposes except for painting bars such as drawing lines and characters (see Figure 1). For instance, the amount of ink consumed in printing the histogram in Figure 1 is:
![](http://acm.hdu.edu.cn/data/images/C38410002.jpg)
Each output value should be a 6 decimal fraction.
Sample Input
3 50
100
0
100
3 50
100
100
50
10 10
1
2
3
4
5
16
17
18
29
30
0 0
Sample Output
0.510000
0.260000
1.476667

回答 1 已采纳 Description
How much does winning ACM depend on practice?
We assume that p, the probability that a given team will win a given contest, is related to n, the number of practice problems solved by the team prior to the contest. This relationship is modelled by the logistic formula
log(p/(1p)) = a + bn ,
for some a and b. Your job is to find a and b such that the formula most accurately reflects a set of observed results.
Each observation consists of n and w. n is the number of practice problems solved by some team prior to a contest, and w is 1 if the team wins the contest, 0 if it does not.
Given a, b, and n the formula above may be used to compute p, the estimated probability that w = 1. The likelihood of a particular observation is p if w = 1 and 1p if w = 0; The likelihood of a set of observations is the product of the likelihoods of the individual observations.
You are to compute the maximum likelihood estimate for a and b. That is, the values of a and b for which the likelihood of a given set of observations is maximized.
Input
The input contains several test cases followed by a line contatining 0. Each test case begins with 1 < k <= 100, the number of observations that follow. Each observation consists of integers 0 <= n <= 100 and 0 <= w <= 1. The input will contain at least two distinct values of n and of w.
Output
For each test case, output a single line containing a and b, rounded to four digits to the right of the decimal.
Sample Input
20
0 0
0 0
0 0
0 0
1 0
1 0
1 0
1 1
2 0
2 0
2 1
2 1
3 0
3 1
3 1
3 1
4 1
4 1
4 1
4 1
0
Sample Output
3.1748 1.5874

回答 1 已采纳 Problem Description
As we all know, in the computer science, an integer A is in the range of 32signed integer, which means the integer A is between 2^31 and (2^31)1 (inclusive), and A is a 64signed integer, which means A is between 2^63 and (2^63)1(inclusive). Now we give the Ksigned range, and two Ksigned integers A and B, you should check whether the sum of A and B is beyond the range of Ksigned integer or not.
Input
There will be many cases to calculate. In each case, there comes the integer K (2<=K<=64) first in a single line. Then following the line, there is another single line which has two Ksigned integers A and B.
Output
For each case, you should estimate whether the sum is beyond the range. If exceeded, print “Yes”, otherwise “WaHaHa”.
Sample Input
32
100 100
Sample Output
WaHaHa

回答 1 已采纳 Problem Description
Triangulation of surfaces has applications in the Finite Element Method of solid mechanics. The objective is to estimate the stress and strain on complex objects by partitioning them into small simple objects which are considered incompressible. It is convenient to approximate a plane surface with a simple polygon, i.e., a piecewiselinear, closed curve in the plane on m distinct vertices, which does not intersect itself. A chord is a line segment between two nonadjacent vertices of the polygon which lies entirely inside the polygon, so in particular, the endpoints of the chord are the only points of the chord that touch the boundary of the polygon. A triangulation of the polygon, is any choice of m  3 chords, such that the polygon is divided into triangles. In a triangulation, no two of the chosen chords intersect each other, except at endpoints, and all of the remaining (unchosen) chords cross at least one of the chosen chords. Fortunately, finding an arbitrary triangulation is a fairly easy task, but what if you were asked to find the best triangulation according to some measure?
Figure I.1: Five out of nine possible triangulations of the example polygon. The leftmost has
the smallest largest triangle.
Input
On the first line of the input is a single positive integer n, telling the number of test scenarios to follow. Each scenario begins with a line containing one positive integer 2 < m < 50, being the number of vertices of the simple polygon. The following m lines contain the vertices of the polygon in the order they appear along the border, going either clockwise or counter clockwise, starting at an arbitrary vertex. Each vertex is described by a pair of integers x y obeying 0 <= x <= 10 000 and 0 <= y <= 10 000.
Output
For each scenario, output one line containing the area of the largest triangle in the triangulation of the polygon which has the smallest largest triangle. The area should be presented with one fractional decimal digit.
Sample Input
1
6
7 0
6 2
9 5
3 5
0 3
1 1
Sample Output
9.0

回答 2 已采纳 watashi is a sport lover and he selects different kind of PE every semester. Usually he is satisfied with his choose, but this term, after the first badminton class started, he gets mad with the teacher "Satan. ChenTooBad" at his snap at the students with no reason at the first sight of them.
watashi will revenge to "Satan. ChenTooBad"'s impertinence. Finally, the end of semester comes, the students have right to estimate the teacher. That's the revenge moment, watashi thought.
Each student can give an integer mark form 1 to N to the teacher he/she is estimating. A teacher's rating is the average of marks given by students rounded to 0.1 (for example, 8.34 is rounded to 8.3, and 8.65 and 8.68 are rounded to 8.7). watashi knows "Satan. ChenTooBad" has been valued by M visitors and its current rating is K (rounded).
If a teacher's rating is not greater than L, he/she will be fired. Evil watashi wants to drag "Satan. ChenTooBad" out of his university as the final revenge.
Now watashi only knows the four numbers, can you help watashi to determine how many votes watashi must cast in order to achieve the revenge (assure that Satan will be fired).
Input
Each block has only one line. It contains four numbers N, K, L and M. The numbers K, L are given with one fractional digit. 1 <= N <= 100. 1 <= K, L <= N. 1 <= M <= 1000000.
You can make sure that the input is always valid (K is achievable by M visitors).
Output
Output the minimal number of estimates that guarantee that "Satan. ChenTooBad "will be fired. If it is impossible to achieve, just output "1".
Sample Input
10 5.1 4.6 50
Sample Output
7

hellspawn88的博客 [Ethereum Tutorial]Depoly contract on the private chainIntroduction:This tutorial shows you how to write contracts, compile contracts, and deploy contracts to your own private chain and call contract ... 
小溪的博客 https://github.com/ConsenSys/smartcontractbestpractices ...Ethereum Contract Security Techniques and Tips The recent attack on The DAO highlights the importance of security and proper soft 
FLy_鹏程万里的博客 Deploy New Contract . On the Solidity Contract Source code text field, type the code below: contract MyToken { /* This creates an array with all balances */ mapping (address => uint256) ... 
weixin_26747751的博客 Often this is used when a user can’t pay for the gas associated with the transaction. 让我们以一个简单的中继器合同为例。 如下所示，中继合同允许某人进行交易并签署交易，而不必执行交易。 当用户无法支付... 
笔名辉哥的博客 contract Crowdsale { address public beneficiary; // 募资成功后的收款方 uint public fundingGoal; // 募资额度 uint public amountRaised; // 参与数量 uint public deadline; // 募资截止期 uint public ... 
jerryfleming的博客 there is an inviolable industry standard that prohibits examining our failures.) Suppose, before all the participants had scurried off for cover, you got a chance to figure out what had gone wrong.... 
csdn1896的博客 *Submitted for verification at Etherscan.io on 20170815 */ pragma solidity ^0.4.11; contract Owned { address public owner; function Owned() { owner = msg.sender; } ... 
Allen_ke的博客 contract Crowdsale { address public beneficiary; // 募资成功后的收款方 uint public fundingGoal; // 募资额度 uint public amountRaised; // 参与数量 uint public deadline; // 募资截止期 uint public ... 
weixin_34336292的博客 Privileges Needed for Installation and Operation ........................ 17 Minimum Client Permissions Needed for P6 Professional ................................. 18 Physical Security ... 
weixin_38169562的博客 100 the be and of a in to have ...for you he with on do say this they at but we his from not by she or as what go their can who get if would her all... 
guanjianhe的博客 单词 a abandon abbreviation ability able abnormal aboard abolish abortion about above abroad absence absent absolute absolutely absorb abstract absurd abuse academic academy ...accen... 
dearbaba_1666的博客 &lt;?php // Plugin 8: Spell Check // This is an executable example with additional code supplie