Make sure that you understand the situation. First, sumk = (K1 + K2) ^ K * sum, and then we need to discuss the situation based on k1 + K2. For details, seeCode:
# Include <stdio. h> # include <stdlib. h> # include <math. h> int t; int N; double K1, K2 ;__ int64 K, sum; int TMP; int main () {scanf ("% d", & T ); INT cases = 1; while (t --) {scanf ("% d % lf % i64d", & N, & K1, & K2, & K ); printf ("case # % d:", cases ++); sum = 0; For (INT I = 0; I <n; I ++) {scanf ("% d", & TMP); sum + = TMP;} If (sum> K) printf ("0 \ n "); else if (K1 + K2 <= 1 & k1 + k2> = 0 | k1 + K2 <0 & k1 + k2> =-1) printf ("INF \ n"); else if (K1 + K2 <-1) {_ int64 I; for (I = 2; I + = 2) if (POW (K1 + K2, I) * sum> K) break; printf ("% i64d \ n", I);} else if (K1 + k2> 1) {__ int64 I; for (I = 1; I ++) {If (POW (K1 + K2, I) * sum> K) break ;} printf ("% i64d \ n", I) ;}// system ("pause"); Return 0 ;}