Skip to content

Commit

Permalink
Problema: 3444
Browse files Browse the repository at this point in the history
  • Loading branch information
lrlucena committed Sep 21, 2024
1 parent c7529dd commit a99335a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Join the chat at https://gitter.im/potigol/Potigol](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/potigol/Potigol?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Follow us](https://img.shields.io/twitter/follow/potigol.svg?style=social)](http://twitter.com/potigol)
[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/potigol/beecrowd)
[![Soluções](https://img.shields.io/badge/Problemas%20Resolvidos-817-blue)](https://github.com/potigol/beecrowd/commits/master)
[![Soluções](https://img.shields.io/badge/Problemas%20Resolvidos-818-blue)](https://github.com/potigol/beecrowd/commits/master)

<!-- a href="https://potigol.github.io/docs/hacktoberfest"><img src="https://hacktoberfest.digitalocean.com/_nuxt/img/logo-hacktoberfest-full.f42e3b1.svg" width=250></a -->

Expand Down
28 changes: 10 additions & 18 deletions src/3400/3444.poti
Original file line number Diff line number Diff line change
@@ -1,31 +1,23 @@
pot2(k: Inteiro) = BigInt(2).pow(k)
pot2(k: Inteiro, p: BigInt) = BigInt(2).pow(k) - (p + 1)

a = leia_textos(" ")
n = a[1].inteiro
var p, h := BigInt(a[2]) - 1 , BigInt(a[3]) - 1

w = para k de n até 1 passo -1 gere
c = (h >= pot2(k - 1))
se c então h := pot2(k) - 1 - h fim
c = pot2(k - 1, h) <= -1
se c então h := pot2(k, h) fim
c
fim

V, F = verdadeiro, falso
ans = para k de n até 1 passo -1 gere
se w[k] então
se p < pot2(k-1) então
p := pot2(k - 1) - 1 - p
'L'
senão
p := pot2(k) - 1 - p
'R'
fim
senão
se p < pot2(k - 1) então
'R'
senão
p := p - pot2(k-1)
'L'
fim
pk1 = pot2(k - 1, p)
escolha (w[k], pk1 >= 0)
caso (V, V) => p := pk1 'L'
caso (F, F) => p := -(pk1 + 1) 'L'
caso (V, F) => p := pot2(k, p) 'R'
caso (F, V) => 'R'
fim
fim
escreva ans.junte("")

0 comments on commit a99335a

Please sign in to comment.