#include <stdio.h>

double calculate_exact_cooldown_seconds(double distance) {
    if (distance <= 0) return 0.0;
    
    // 0km ~ 1km 구간 (0분 ~ 1분 비례)
    if (distance < 1.0) {
        return distance * 60.0; 
    }
    // 1km ~ 5km 구간 (1분 ~ 2분 비례)
    if (distance <= 5.0) {
        return 60.0 + (distance - 1.0) * ((2.0 - 1.0) * 60.0 / (5.0 - 1.0));
    }
    // 5km ~ 10km 구간 (2분 ~ 7분 비례)
    if (distance <= 10.0) {
        return 120.0 + (distance - 5.0) * ((7.0 - 2.0) * 60.0 / (10.0 - 5.0));
    }
    // 10km ~ 100km 구간 (7분 ~ 35분 비례)
    if (distance <= 100.0) {
        return 420.0 + (distance - 10.0) * ((35.0 - 7.0) * 60.0 / (100.0 - 10.0));
    }
    // 100km ~ 500km 구간 (35분 ~ 60분 비례)
    if (distance <= 500.0) {
        return 2100.0 + (distance - 100.0) * ((60.0 - 35.0) * 60.0 / (500.0 - 100.0));
    }
    // 500km ~ 1500km 구간 (60분 ~ 120분 비례)
    if (distance < 1500.0) {
        return 3600.0 + (distance - 500.0) * ((120.0 - 60.0) * 60.0 / (1500.0 - 500.0));
    }
    
    // 1500km 이상: 무조건 2시간(120분 = 7200초)
    return 7200.0; 
}

int main() {
    double distance;
    
    printf("========== GPSharp 정밀 쿨다운 계산기 ==========\n");
    printf("이동할 거리(km)를 입력하세요: ");
    
    if (scanf("%lf", &distance) != 1) {
        printf("올바른 숫자를 입력해주세요.\n");
        return 1;
    }
    
    double total_seconds = calculate_exact_cooldown_seconds(distance);
    
    int total_seconds_rounded = (int)(total_seconds + 0.5);
    int mins = total_seconds_rounded / 60;
    int secs = total_seconds_rounded % 60;
    
    printf("\n[계산 결과]\n");
    printf("이동 거리: %.2f km\n", distance);
    
    if (total_seconds_rounded >= 7200) {
        printf("권장 대기시간: 무조건 2시간 (120분 00초)\n");
    } else {
        printf("권장 대기시간: 약 %d분 %02d초\n", mins, secs);
    }
    printf("====================================================\n");
    
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: