#30956: cpp 解答 + 題目解釋


allenwu981002@gmail.com (貓帥帥)

School : 德光中學
ID : 192608
IP address : [106.105.221.158]
Last Login :
2024-03-23 18:53:10
a536. 11689 - Soda Surpler -- UVa11689 | From: [218.210.47.99] | Post Date : 2022-06-24 23:53

#include <iostream>
using namespace std;
int main() 
{
  int e, i , n , f, g, sodas = 0;
  cin >> n ;
  for (int i = 0; i < n ; i++) 
  {
  
  cin >> e >> f >> g;
  e += f;
  sodas=0;
  while (e >= g) 
  {
    int temp = e;
    e /= g;
    sodas += e;
    e += temp % g;
  }
  cout << sodas << endl;
}
return 0 ;
}

 
ZeroJudge Forum