Topic:
Triangular area
As shown in Figure 1. All the squares in the chart are 1 in size.
So what should be the area of the triangle in the figure?
Please fill in the area of the triangle. Do not fill in any superfluous content or descriptive text.
Chuchu Solutions:
1 PackagePackage1;2 ImportJava.util.Scanner;3 4 Public classQ2 {5 intx;6 inty;7 Static classlocate{8 Private intx;9 Private inty;Ten OneLocateintXinty) { A This. x =x; - This. y =y; - } the - Static Doublegetdist (Locate l1,locate L2) { - returnMath.sqrt ((l1.x-l2.x) * (l1.x-l2.x) + (L1.Y-L2.Y) * (l1.y-l2.y)); - } + } - + Static DoubleHailun (DoubleADoubleBDoublec) { A Doublep = (a+b+c)/2.0; at Doubleres = MATH.SQRT (p* (p-a) * (p-b) * (P-c)); - returnRes; - } - - Public Static voidMain (string[] args) { - in //Scanner input = new Scanner (system.in); -Locate A =NewLocate (4,0); toLocate B =NewLocate (0,8); +Locate C =NewLocate (8,6); - the DoubleAB =locate.getdist (A, B); * DoubleBC =locate.getdist (C, B); $ DoubleAC =locate.getdist (A, C);Panax Notoginseng - DoubleAns =Hailun (AB,AC,BC); the System.out.println (ans); + A the } +}
Topic Two:
Cubic Change itself
Observe the following phenomenon, the cubic of a number, the bitwise accumulation is still equal to itself.
1^3 = 1
8^3 = 512 5+1+2=8
17^3 = 4913 4+9+1+3=17
...
Would you please calculate the total number of positive integers that conform to this property, including 1,8,17?
Please fill in this number, do not fill in any superfluous content or descriptive text.
Solution:
1 PackageCH3;2 3 ImportJava.util.Scanner;4 5 Public classTest2 {6 Public Static voidMain (String args[]) {7 for(inti = 0; i < 1000000; i++) {8 9 LongNumber = i * I *i;Ten intsum = 0; One while(Number! = 0) { ASum + = number% 10; -Number = NUMBER/10; - } the - if(Sum = =i) { - System.out.println (i); - + } - + } A at } - -}
java--Blue Bridge cup real problem