Skip to content

Instantly share code, notes, and snippets.

@lawrencefmm
Created March 12, 2019 14:33
Show Gist options
  • Save lawrencefmm/d25a91a29c081bfa98f414ff2742779f to your computer and use it in GitHub Desktop.
Save lawrencefmm/d25a91a29c081bfa98f414ff2742779f to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, k;
while(cin >> n >> k)
{
int casca = 0;
int pao = 0;
while(n)
{
pao += n; // como os pães disponíveis
casca += n; // tiro as cascas dos pães disponíveis
n = casca/k; // formo novos pães com as cascas
casca %= k; // guardo as cascas que sobraram
}
cout << pao << "\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment