This is the 12th day of my participation in the November Gwen Challenge. Check out the event details: The last Gwen Challenge 2021
【PTA group Program Design Ladder Competition 】
L1-060 psychological shadow area (5) the Go | Golang
This is a map of the area of mental shadow. We all think we can move forward at a constant pace (blue line), while late procrastinators tend to rush frantically at the last minute (red broken line). The area enclosed by the red and blue lines is the psychological shadow area when we are doing homework. Now give the coordinates of red inflection point (x,y), ask you to calculate this psychological shadow area.
Input format:
The input gives two positive integers x and y, not more than 100, in one line, and guarantees that x>y. It is assumed that the maximum value (deadline and final completion) of both horizontal and vertical coordinates is 100.
Output format:
Output mental shadow area in one line.
Friendly reminder: triangle area = base length x height / 2; Area of the rectangle is equal to base length x height. 嫑 think too complex, this is a 5 points test subtraction problem……
Input Example 1:
90 10
Copy the code
No blank line at the end
Example 1:
4000
Copy the code
No blank line at the end
Ideas:
This one problem everybody does not want of too complex, it is a mathematics show actually just, come according to the formula good, the two triangles that big triangle reduces will go a square again can! That’s what this graph shows.
The code is as follows:
package main
import "fmt"
func main(a) {
var a,b float64
_,_ = fmt.Scan(&a,&b)
a1 := a*b/2
a2 :=(100-a)*(100-b)/2
a3 := (100-a)*b
res := 100*100/2-a1-a2-a3
fmt.Printf("%d".int(res))
}
Copy the code
The last
Xiao Sheng Fan Yi, looking forward to your attention.