#include #include #include #include #include #define max(x,y) ((x)<(y)?(y):(x)) #define min(x,y) ((x)<(y)?(x):(y)) #define oo 1000000000 #define CHOP(s) s[strlen(s)-1]='\0' #define DBG(x) x #define MSG(x) printf(x); FILE *input; void solvecase( int kase) { int P, U, I; double p,u,i,v; char T, c; P=U=I=0; while (1) { fscanf( input, "%c", &c); if (feof(input) || c=='\n') break; if (c=='P' || c=='U' || c=='I') { T=c; fscanf( input, "%c", &c); if (c!='=') continue; fscanf( input, " %lf", &v); fscanf( input, "%c", &c); if (c=='m') v*=0.001; else if (c=='k') v*=1000.0; else if (c=='M') v*=1000000.0; if (T=='P'){ assert(P==0); P=1; p = v; } else if (T=='U'){ assert(U==0); U=1; u = v; } else if (T=='I'){ assert(I==0); I=1; i = v; } } } printf("Problem #%d\n", kase); if (!U) printf("U=%.2fV\n", p/i); if (!I) printf("I=%.2fA\n", p/u); if (!P) printf("P=%.2fW\n", u*i); printf("\n"); } int main() { int kase = 0, n; input = fopen( "ai.in", "r"); assert(input!=NULL); fscanf( input, " %d ", &n); for (kase=1; kase<=n; kase++) solvecase(kase); return 0; }