Rezultati

Up. imeNalogaJezikRezultatČas oddaje
finalsolution-2018 Fruit Ninja C 100/100OK 13. okt '18 @ 11:27

Test Točke Porabljen spomin Porabljen čas Status
#1 11/11 1,488 MiB 0,000 s OK
#2 11/11 1,488 MiB 0,000 s OK
#3 11/11 1,488 MiB 0,000 s OK
#4 11/11 1,461 MiB 0,005 s OK
#5 11/11 1,461 MiB 0,005 s OK
#6 11/11 1,461 MiB 0,005 s OK
#7 11/11 1,488 MiB 0,000 s OK
#8 11/11 1,484 MiB 0,000 s OK
#9 12/12 1,488 MiB 0,005 s OK

Ocenjevani program (fruitninja.c):
#include <stdio.h>

int main() {
    int n = 0, m = 0;
    double xa = 0, ya = 0, xb = 0, yb = 0;
    scanf("%lf %lf %lf %lf", &xa, &ya, &xb, &yb);
    scanf("%d", &n);
    double sx = xb - xa, sy = yb - ya;
    while ((n--) > 0) {
        double p = 0, q = 0, r = 0;
        scanf("%lf %lf %lf", &p, &q, &r);
        double tx = p - xa, ty = q - ya;
        double ux = p - xb, uy = q - yb;
        double k = (sx * tx + sy * ty) / (sx * sx + sy * sy);
        double d = (tx - k * sx) * (tx - k * sx) + (ty - k * sy) * (ty - k * sy);
        if (d <= r * r && k >= 0 && k <= 1) m++;
        else if (tx * tx + ty * ty <= r * r) m++;
        else if (ux * ux + uy * uy <= r * r) m++;
    }
    printf("%d\n", m);
    return 0;
}