acm hdu p1021 Fibonacci Again java解答 水水 找规律

Fibonacci Again

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 44697    Accepted Submission(s): 21341

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

根据前辈们找的规律   8*k+2或8*k+6   k为自然数

package HDU;
import java.util.Scanner;
public class p1021 {
 public static void main(String[] args) {
     Scanner sc=new Scanner(System.in);
      while(sc.hasNext()){
    	  int n=sc.nextInt();
    	  if(n%8==2||n%8==6){
    		  System.out.println("yes");
    	  }else{
    		 System.out.println("no");
    	  }
      }

    }

}



时间: 2024-10-11 01:33:57

acm hdu p1021 Fibonacci Again java解答 水水 找规律的相关文章

HDU 5351——MZL&#39;s Border——————【高精度+找规律】

MZL's Border Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 944    Accepted Submission(s): 306 Problem Description As is known to all, MZL is an extraordinarily lovely girl. One day, MZL was pl

2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6154 CaoHaha&#39;s staff(几何找规律)

Problem Description "You shall not pass!"After shouted out that,the Force Staff appered in CaoHaha's hand.As we all know,the Force Staff is a staff with infinity power.If you can use it skillful,it may help you to do whatever you want.But now,hi

HDU 4588 Count The Carries(数学 二进制 找规律啊)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4588 Problem Description One day, Implus gets interested in binary addition and binary carry. He will transfer all decimal digits to binary digits to make the addition. Not as clever as Gauss, to make th

【递推】【HDU 2073】无限的路 (找规律)

链接:http://acm.hdu.edu.cn/showproblem.php?pid=2073 意外之喜  还挺不错的一道题目 仔细观察不难发现   其实整个路线只有这两种线(绿色跟红色) 并且在移动过程中[x,y]的改变(红线部分)总是遵循这两种规律[x+1,y-1]或者[x-1,y+1],设x+y=z 在同一条红线中z的值是不变的 既然如此 我们不如直接用x+y来计算红线部分的总值,忽略x与y的具体数值 我们定义一个数组p1[z]来保存红线的前缀和 计算公式也很容易看出来p1[0] =

acm hdu p2547 无剑无我{水水水}

无剑无我 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4112    Accepted Submission(s): 2638 Problem Description 北宋末年,奸臣当道,宦官掌权,外侮日亟,辽军再犯.时下战火连连,烽烟四起,哀鸿遍野,民不聊生,又有众多能人异士群起而反,天下志士云集响应,景粮影从. 值此危急存亡之秋

hdu 1564 Play a game(博弈找规律)

题目:一个n*n的棋盘,每一次从角落出发,每次移动到相邻的,而且没有经过的格子上. 谁不能操作了谁输. 思路:看起来就跟奇偶性有关 走两步就知道了 #include <iostream> using namespace std; int main() { int n; while(cin>>n&&n) { if((n*n-1)%2!=0) cout<<"8600"<<endl; else cout<<"

HDU 1046.Gridland【非搜索,找规律】【8月25】

Gridland Problem Description For years, computer scientists have been trying to find efficient solutions to different computing problems. For some of them efficient algorithms are already available, these are the "easy" problems like sorting, ev

HDU 1337 The Drunk Jailer--(模拟题找规律)

题意:有n个监狱,共n轮,第 i 轮警察会去编号为 i 的倍数的监狱,如果是锁的就开锁,如果是开的就锁上,求n轮过后有多少犯人会逃出来 分析:这题实际上是个模拟题,因为数据很小我直接用两重循环模拟的,如果数据很大的话,就不能直接模拟了,模拟题卡时间多半是找规律. 这题的规律是:如果一个监狱被查看了偶数次的话相当于则什么都没发生,还是锁的,也就是说找没有锁上的监狱只要n以内找因数为奇数个的数有多少个即可 代码: #include<iostream> using namespace std; in

Just Random HDU - 4790 思维题(打表找规律)分段求解

Coach Pang and Uncle Yang both love numbers. Every morning they play a game with number together. In each game the following will be done:  1. Coach Pang randomly choose a integer x in [a, b] with equal probability.  2. Uncle Yang randomly choose a i