Fibonacci Again

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 30227    Accepted Submission(s): 14685

Problem Description
There are another kind of Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2).
 
Input
Input consists of a sequence of lines, each containing an integer n. (n < 1,000,000).
 
Output
Print the word "yes" if 3 divide evenly into F(n).
Print the word "no" if not.
 
Sample Input
0
1
2
3
4
5
 
Sample Output
no
no
yes
no
no
no
 
Author
Leojay
 
 #include <stdio.h>

 int main()
{
int f[];
int n;
while(scanf("%d",&n)!=EOF)
{
int i,xh;
f[]=%;
f[]=%;
for(i=;i<;i++)
{
f[i]=(f[i-]+f[i-])%;
if(f[i]==&&f[i-]==)
break;
}
xh=i-;
n=n%xh;
if(f[n]==)
printf("yes\n");
else
printf("no\n");
}
return ;
}

思路详见hdu_1005  这两题类似

 

hdu_1021_Fibonacci Again_201310232237的更多相关文章

随机推荐

  1. ecshop的一些东西,来看看

    \includes\lib_commom.php =>公用函数库 \includes\lib_main.php =>前台公用函数库 \includes\lib_init.php => ...

  2. 【转】关于Java基础你不得不会的34个问题

    1. 面向对象和面向过程的区别 面向过程 优点: 性能比面向对象高,因为类调用时需要实例化,开销比较大,比较消耗资源;比如单片机.嵌入式开发.Linux/Unix等一般采用面向过程开发,性能是最重要的 ...

  3. 深入Mysql字符集设置

    作者: Laruence(   ) 本文地址: http://www.laruence.com/2008/01/05/12.html 转载请注明出处 根据Chaos  Wang的PPT整理而成, 在此 ...

  4. cloudera-scm-server启动时出现Caused by: java.io.FileNotFoundException: /var/lib/cloudera-scm-server/.keystore (No such file or directory)问题解决方法(图文详解)

    不多说,直接上干货! 问题详情 查看/var/log/cloudera-scm-server.log的启动日志 问题来源 我在用cloudermanager安装好之后,然后,在对如下. 配置kerbe ...

  5. 【Java基础】多态

    首先先来个总结: 什么是多态 面向对象的三大特性:封装.继承.多态.从一定角度来看,封装和继承几乎都是为多态而准备的.这是我们最后一个概念,也是最重要的知识点. 多态的定义:指允许不同类的对象对同一消 ...

  6. PHP配置步骤

    背景: 作为web前端人员,必不可少的会接触到一些服务器端的脚本语言,比如PHP.因为最近在进行相关知识的总结,同时也回顾一下PHP基础知识.这次总结先从PHP的开始说起,即PHP的配置步骤. 什么是 ...

  7. (一)Python 学习第一天--基础知识,列表

    1. .pyc文件 .pyc文件:在python3中,当模块运行时会自动生成在_pycache_文件夹中,其中c为compiled的缩写. Python是一门现编译后解释的语言,在运行时首先寻找.py ...

  8. Logstash_Apache日志采集

    [root@Cagios logstash-]# cat /usr/local/logstash-/logstash_agent.conf input { file { type => &quo ...

  9. HDU_1068_Girls and Boys_二分图匹配

    Girls and Boys Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  10. 一台电脑同时使用多个Git账号

    参照 https://my.oschina.net/u/3578363/blog/2209781