若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。


  • 运维

  • 前端

  • 编程

  • 随笔

  • hust-oj

1203: sqrt log sin

发表于 2017-10-06   |   分类于 HUSTOJ   |   阅读次数 1,306

题目描述

An evil professor has just assigned you the following problem.
A sequence is defined by the following recurrence:

Determine
x1000000
.

输入

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.

输出

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

样例输入

0
-1

样例输出

1

参考代码

# include<stdio.h>
# include<math.h>
int a[1000001];
int main(void) 
{
    int i,n;
    a[0] = 1;
    for (i=1;i<=1000000;i++)
            a[i] = (a[(int)floor(i-(sqrt(i)))]
                  + a[(int)floor(i*sin(i)*sin(i))]
                  + a[(int)floor(log(i))])% 1000000;
    while(scanf("%d",&n)!=EOF) 
    {
        if(n == -1) break;
        printf("%dn",a[n]);
    }
    return 0;
}

解析

暂无

hustoj

发表评论 取消回复

电子邮件地址不会被公开。 必填项已用*标注

*
*


hoxis wechat
著作权归作者所有
站点更新说明
  • 文章目录
  • 站点概览
若是凉夜已成梦

若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。

1904 日志
6 分类
12 标签
RSS
weibo github twitter facebook

友情链接

原站点 Dreams孤独患者 Skip
© 2017 若是凉夜已成梦
Powered by WordPress | 已运行
Theme By NexT.Mist