标签:
题意:给定两个人民币,问你花最少钱保证能够凑出另一个价格。
析:这个题最大的坑就是在,并一定是一次就凑出来,可以多次,然后就可以想了,如果要凑的数和1有关,特判,如果是2倍数,0.01就够了,否则就是0.01.
代码如下:
#include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #include <cstring> #include <set> #include <queue> #include <algorithm> #include <vector> #include <map> #include <cctype> using namespace std ; typedef long long LL; typedef pair<int, int> P; const int INF = 0x3f3f3f3f; const double inf = 0x3f3f3f3f3f3f3f; const double eps = 1e-12; const int maxn = 1e6 + 5; const int dr[] = {0, 0, -1, 1}; const int dc[] = {-1, 1, 0, 0}; int main(){ int T; cin >> T; double a, b; for(int kase = 1; kase <= T; ++kase){ scanf("%lf %lf", &b, &a); printf("Case #%d: ", kase); if(0.01 == a || 0.1 == a || 1 == a || 10 == a){ if(b == a * 2.0) printf("0.01\n"); else printf("0.02\n"); } else printf("0.01\n"); } return 0; }
标签:
原文地址:http://www.cnblogs.com/dwtfukgv/p/5726894.html