Thursday, November 16, 2017

1035 - Sqrt Log Sin COJ Problem Solution


http://coj.uci.cu/24h/problem.xhtml?pid=1035



In C++..................................

#include <stdio.h>
#include <math.h>
#define mod 1000000

int x[1000005];

void calcula()
{
    int i;
    double d;

    x[0] = 1;
    for(i = 1; i <= 1000000; i++){
        d = i;
        x[i] = (x[(int)(d-sqrt(d))]%mod + x[(int)log(d)]%mod + x[(int)(d*sin(d)*sin(d))]%mod)%mod;
    }
}

int main()
{
    int n;

    calcula();
    while(1)
    {
        scanf("%d", &n);
        if(n == -1) break;
        printf("%d\n", x[n]);
    }
    return 0;
}

No comments:

Post a Comment