ural 1283. Dwarf
1283. Dwarf
Time limit: 1.0 second
Memory limit: 64 MB
Memory limit: 64 MB
Venus dwarfs are rather unpleasant creatures: ugly, malicious, and mean-spirited. Maybe it’s because of hard living conditions on their planet… but the fact remains: each of them is ready to sell his own mother in order to save up his pot of gold and to preserve it to the end of his days.
The dwarfs are especially nervous about the Mercury leprechauns who are always glad to empty a dwarf’s pot and to fill it with solar dust instead of the gold. The dwarfs are weak-sighted and can’t distinguish dust from gold. That is why each dwarf once a year visits the Central Galaxy Bank (CGB), where experienced specialists authenticate the content of the pot taking a small commission for the job.
When the amount of gold in a pot becomes less than or equal to a certain level, the life of a dwarf has no sense anymore, so he clears the world of his wretched soul: with the remaining gold he buys in a zoo the largest Jupiter toad and creeps under it which results in crushing his chest.
Input
The input contains three integers separated with spaces. The first number is the amount of gold in a dwarf’s pot at the initial moment. The second number is the amount of gold at which the dwarf’s life becomes senseless. Both values are measured in grams and don't exceed 231 − 1. The third number is the CGB commission (from 1 to 100); this is the percentage of gold that is taken from the pot as a way of payment for the verification.
Output
The output should contain the number of years that is left to the dwarf.
Samples
input | output |
---|---|
19 10 50 |
1 |
1000 1 1 |
688 |
Problem Author: Leonid Volkov (prepared by Ivan Dashkevich)
Problem Source: USU Personal Contest 2004
Problem Source: USU Personal Contest 2004
Tags: none
Difficulty: 129
题意:输入一个数n,m表示钱的数量和下限(达到下限也会死),一个数k从1到100,表示每年用掉的钱的百分比,然后问多少年死?
分析:暴力
1 #include <cstdio> 2 #include <cstring> 3 #include <cstdlib> 4 #include <cmath> 5 #include <deque> 6 #include <vector> 7 #include <queue> 8 #include <iostream> 9 #include <algorithm> 10 #include <map> 11 #include <set> 12 #include <ctime> 13 using namespace std; 14 typedef long long LL; 15 typedef double DB; 16 #define For(i, s, t) for(int i = (s); i <= (t); i++) 17 #define Ford(i, s, t) for(int i = (s); i >= (t); i--) 18 #define Rep(i, t) for(int i = (0); i < (t); i++) 19 #define Repn(i, t) for(int i = ((t)-1); i >= (0); i--) 20 #define rep(i, x, t) for(int i = (x); i < (t); i++) 21 #define MIT (2147483647) 22 #define INF (1000000001) 23 #define MLL (1000000000000000001LL) 24 #define sz(x) ((int) (x).size()) 25 #define clr(x, y) memset(x, y, sizeof(x)) 26 #define puf push_front 27 #define pub push_back 28 #define pof pop_front 29 #define pob pop_back 30 #define ft first 31 #define sd second 32 #define mk make_pair 33 inline void SetIO(string Name) 34 { 35 string Input = Name + ".in", 36 Output = Name + ".out"; 37 freopen(Input.c_str(), "r", stdin), 38 freopen(Output.c_str(), "w", stdout); 39 } 40 41 inline int Getint() { 42 int Ret = 0; 43 char Ch = ' '; 44 bool Flag = 0; 45 while(!(Ch >= '0' && Ch <= '9')) 46 { 47 if(Ch == '-') Flag ^= 1; 48 Ch = getchar(); 49 } 50 while(Ch >= '0' && Ch <= '9') { 51 Ret = Ret * 10 + Ch - '0'; 52 Ch = getchar(); 53 } 54 return Flag ? -Ret : Ret; 55 } 56 57 const DB Eps = 1e-6; 58 DB a, b, c; 59 LL Ans; 60 61 inline void Input() { 62 63 } 64 65 inline void Solve() { 66 for(cin >> a >> b >> c; a > b + Eps; a -= a * c / 100.0, Ans++) ; 67 cout << Ans << endl; 68 } 69 70 int main() { 71 #ifndef ONLINE_JUDGE 72 SetIO("A"); 73 #endif 74 Input(); 75 Solve(); 76 return 0; 77 }