Created
March 12, 2019 14:33
-
-
Save lawrencefmm/d25a91a29c081bfa98f414ff2742779f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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