C 40分 找不出问题呜呜呜 dalao help me #2 #3 #5过不去
查看原帖
C 40分 找不出问题呜呜呜 dalao help me #2 #3 #5过不去
843596
Otion楼主2022/11/2 19:29
#include <stdio.h>
#include <math.h>
int main() 
{
    int times=0;
    double health=10;
    double healthchange=0;
    double upwater=0;
    double count=0;
    double mid2=0;
    double mid=0;
    scanf("%d",&times);
    for(int i=0;i<times;i++){
        scanf("%lf %lf",&healthchange,&upwater);    
        mid2=count;
        count=count+upwater;
        mid=health;
        health=health-healthchange;
        if(health<=0){
            health=mid;
            count=mid2;
            break;
        }
    }
    double level=0;
    double t=0;
    while(count!=0){
        if(count-pow(2.0,level)<0){
            t=count;
            count=0;
        }else{
        count=count-pow(2.0,level);
        level++;
        }
    }
    printf("%.0f %.0f",level,t);
    return 0;
}
2022/11/2 19:29
加载中...