Advertisement
Guest User

Untitled

a guest
Feb 9th, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <cassert>
  3. #include <cstdio>
  4. #include <set>
  5. #include <map>
  6. #include <vector>
  7. #include <queue>
  8. #include <stack>
  9. #include <cmath>
  10. #include <algorithm>
  11. #include <cstring>
  12. #include <ctime>
  13. #include <stack>
  14. #include <list>
  15. using namespace std;
  16. typedef long long li;
  17. typedef long double ld;
  18. typedef vector<int> vi;
  19. typedef pair<int, int> pi;
  20.  
  21. #define mp make_pair
  22. #define pb push_back
  23. #define all(s) s.begin(), s.end()
  24. li solve();
  25.  
  26. int main() {
  27.     FILE* x = freopen("input", "r", stdin);
  28. #ifdef DEBUG
  29.  
  30.     clock_t start = clock();
  31. #else
  32.     x = freopen("output", "w", stdout);
  33. #endif
  34.     (void)x;
  35.     ios_base::sync_with_stdio(false);
  36.     int t = 1;
  37.     cin >> t;
  38.     string s;
  39.     getline(cin,s );
  40.     for(int i = 1; i <= t; ++i){
  41.         cout << "Case #" << i << ": " << solve() << '\n';
  42.     }
  43.  
  44. #ifdef DEBUG
  45.     cout << "\n\n\nTime:" << ((clock() - start) / 1.0 / CLOCKS_PER_SEC);
  46. #endif
  47.     return 0;
  48. }
  49.  
  50.  
  51. li solve(){
  52.     li n, k;
  53.     int p;
  54.     cin >> n >>k >>p;
  55.     li add = n % k;
  56.     if(!add)
  57.         add += k;
  58.    
  59.     if(p == 100)
  60.         return (n - add) / k + 1;
  61.     while(true){
  62.         // find min t: kt / kt + add >= p / 100
  63.         li t =  (p * add + (100 - p) * k - 1) / ((100 - p) * k);
  64.         if(k * t + add > n)
  65.             break;
  66.         add += k * t;
  67.        
  68.         //cerr << add << endl;
  69.     }
  70.    
  71.     return (n - add) / k + 1;
  72. }
  73.  
  74.  
  75. /*
  76. li solve(){
  77.     li n, k;
  78.     int p;
  79.     cin >> n >> k >> p;
  80.     li with = 0;
  81.     li lastStop = n % k;
  82.     for(li i = n % k + k; i <= n; i += k){
  83.         if((k + with) * 100 >= i * p){
  84.             with = 0;
  85.             lastStop = i;
  86.             cerr << lastStop << endl;
  87.         }
  88.         else
  89.             with += k;
  90.     }
  91.     return (n - lastStop) / k + 1;
  92. }
  93.  *
  94.  * */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement