java--Blue Bridge cup real problem

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.