mirror of
https://github.com/tiennm99/codeforces.git
synced 2026-10-11 03:13:15 +00:00
feat(go): add 791A & 600B
This commit is contained in:
1 parent
20542601dd
commit
9befed87ce
2 files changed
+53
No files matched your search
+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