mirror of
https://github.com/tiennm99/codeforces.git
synced 2026-06-09 10:12:55 +00:00
feat(go): add 791A & 600B
This commit is contained in:
+34
@@ -0,0 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"sort"
|
||||
)
|
||||
|
||||
func main() {
|
||||
in := bufio.NewReader(os.Stdin)
|
||||
var n, m int
|
||||
fmt.Fscan(in, &n, &m)
|
||||
|
||||
a := make([]int, n)
|
||||
for i := range a {
|
||||
fmt.Fscan(in, &a[i])
|
||||
}
|
||||
sort.Ints(a)
|
||||
|
||||
out := bufio.NewWriter(os.Stdout)
|
||||
for i := 0; i < m; i++ {
|
||||
var x int
|
||||
fmt.Fscan(in, &x)
|
||||
|
||||
pos := sort.SearchInts(a, x+1)
|
||||
|
||||
fmt.Fprint(out, pos)
|
||||
if i+1 < m {
|
||||
fmt.Fprint(out, " ")
|
||||
}
|
||||
}
|
||||
out.Flush()
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var a, b int
|
||||
fmt.Scan(&a, &b)
|
||||
|
||||
years := 0
|
||||
for a <= b {
|
||||
a *= 3
|
||||
b *= 2
|
||||
years++
|
||||
}
|
||||
|
||||
fmt.Println(years)
|
||||
}
|
||||
Reference in New Issue
Block a user