UVA 537 Artificial Intelligence?

发布时间:2016-12-6 10:50:37 编辑:www.fx114.net 分享查询网我要评论
本篇文章主要介绍了"UVA 537 Artificial Intelligence?",主要涉及到UVA 537 Artificial Intelligence?方面的内容,对于UVA 537 Artificial Intelligence?感兴趣的同学可以参考一下。

每组输入一句话,包含P,U,I中的两个,求另一个,注意单位。 #include<algorithm> #include<iostream> #include<cstring> #include<cstdio> #include<vector> #include<cmath> ///LOOP #define REP(i, n) for(int i = 0; i < n; i++) #define FF(i, a, b) for(int i = a; i < b; i++) #define FFF(i, a, b) for(int i = a; i <= b; i++) #define FD(i, a, b) for(int i = a - 1; i >= b; i--) #define FDD(i, a, b) for(int i = a; i >= b; i--) ///INPUT #define RI(n) scanf("%d", &n) #define RII(n, m) scanf("%d%d", &n, &m) #define RIII(n, m, k) scanf("%d%d%d", &n, &m, &k) #define RIV(n, m, k, p) scanf("%d%d%d%d", &n, &m, &k, &p) #define RV(n, m, k, p, q) scanf("%d%d%d%d%d", &n, &m, &k, &p, &q) #define RFI(n) scanf("%lf", &n) #define RFII(n, m) scanf("%lf%lf", &n, &m) #define RFIII(n, m, k) scanf("%lf%lf%lf", &n, &m, &k) #define RFIV(n, m, k, p) scanf("%lf%lf%lf%lf", &n, &m, &k, &p) #define RS(s) scanf("%s", s) ///OUTPUT #define PN printf("\n") #define PI(n) printf("%d\n", n) #define PIS(n) printf("%d ", n) #define PS(s) printf("%s\n", s) #define PSS(s) printf("%s ", n) ///OTHER #define PB(x) push_back(x) #define CLR(a, b) memset(a, b, sizeof(a)) #define CPY(a, b) memcpy(a, b, sizeof(b)) #define display(A, n, m) {REP(i, n){REP(j, m)PIS(A[i][j]);PN;}} using namespace std; typedef long long LL; typedef pair<int, int> P; const int MOD = 1000000; const int INFI = 1e9 * 2; const LL LINFI = 1e17; const double eps = 1e-6; const double pi = acos(-1.0); const int N = 1111; const int M = 33; const int move[8][2] = {0, 1, 0, -1, 1, 0, -1, 0, 1, 1, 1, -1, -1, 1, -1, -1}; char s[N]; int main() { //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); int n, t, l; double P, U, I, a, k; RI(n); getchar(); FFF(cas, 1, n) { gets(s); printf("Problem #%d\n", cas); P = U = I = -1; l = strlen(s); REP(i, l) { if(s[i] == '=') { t = i - 1; i++; a = 0; while(isdigit(s[i]))a = a * 10 + s[i++] - '0'; if(s[i] == '.') { k = 10.0; i++; while(isdigit(s[i]))a += (s[i++] - '0' + 0.0) / k, k *= 10.0; } if(s[i] == 'M')a *= 1000000.0; else if(s[i] == 'k')a *= 1000.0; else if(s[i] == 'm')a /= 1000.0; if(s[t] == 'P')P = a; else if(s[t] == 'U')U = a; else if(s[t] == 'I')I = a; } } if(P == -1)printf("P=%.2lfW\n\n", U * I); else if(U == -1)printf("U=%.2lfV\n\n", P / I); else if(I == -1)printf("I=%.2lfA\n\n", P / U); } return 0; }

上一篇:事件的命名空间
下一篇:引用 Delphi操作EXCEL

相关文章

相关评论