想吃冰卻又敏感保護不足?來自星星的你也會打廣告?法人:14檔今年本業虧定了老伯送飲料 遭學生糾察...
2012-05-17 18:46:37 人氣(255) | 回應(0) | 推薦(0) | 收藏(0) 上一篇 | 下一篇

[UVA] 11703 - sqrt log sin

0
收藏
0
推薦

Problem E: sqrt log sin

An evil professor has just assigned you the following problem.

A sequence is defined by the following recurrence:

Determine x1000000.

Input Specification

Input consists of a number of lines, each containing one integer, a value of i, no less than zero and no greater than one million. Input is followed by a single line containing the integer -1. This last line is not a value of i and should not be processed.

Sample Input

0
-1

Output Specification

For each value of i in the input (but not the final -1), output the corresponding value of xi modulo 1000000.

Output for Sample Input

1



#include <stdio.h>
#include <math.h>

int x[1000001] = {1};
int main() {
    int i, a, b, c;
    for(i = 1; i <= 1000000; i++) {
        a = (int)(i-sqrt(i));
        b = (int)log(i);
        c = (int)(i*sin(i)*sin(i));
        x[i] = (x[a]+x[b]+x[c])%1000000;
    }
    while(scanf("%d", &i) == 1 && i >= 0)
        printf("%d\n", x[i]);
    return 0;
}

11703sqrt log sin
台長:Morris
人氣(255) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 不分類 | 個人分類: UVA |
此分類下一篇:[UVA][組何分配] 10910 - Marks Distribution
此分類上一篇:[UVA][DP最大矩形] 10667 - Largest Block

我要回應
是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入以下數字 (ex:123)

(有*為必填)
詳全文