Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // primeren input:
- // 3 // 3 testa
- // 1 20 // panica 1 = 20
- // 2 30 //
- // 3 50 //
- // OUTPUT: 100
- //
- #include <iostream>
- #include <string>
- #include <cstdlib>
- #include <sstream> // std::stringstream
- using namespace std;
- int a = 5;
- int b = 7;
- int x = 2;
- int currentMivkaVol = 0;
- int need,sinkCounter, bottleCounter =0;
- int currentVolume =0;
- int bottleVolume = a;
- int main() {
- bottleCounter = 1;
- while(1)
- {
- need = b-currentVolume;
- if(need >= bottleVolume)
- {
- currentVolume +=bottleVolume;
- bottleVolume-=bottleVolume;
- }
- if(need <= bottleVolume)
- {
- currentVolume += need;
- bottleVolume = bottleVolume - need;
- }
- if(currentVolume == b)
- {
- currentVolume =0;
- sinkCounter++;
- }
- if(bottleVolume == 0)
- {
- bottleVolume = a;
- bottleCounter++;
- }
- if(bottleVolume == x) break;
- }
- cout << bottleCounter << endl;
- cout << sinkCounter++ << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment