NYOJ 480 Fibonacci Again!
Fibonacci Again!
時間限制:1000 ms | 記憶體限制:65535 KB
難度:2
- 描述
-
求第n個斐波那契數是否是一個素數,n為整數f[n]=f[n-1]+f[n-2] (2<n<30)f[1]=3,f[2]=7
- 輸入
- 輸入整數m,0<m<30,輸入-1表示結束輸入
- 輸出
- 如果f[m]是素數 則輸出Yes,否則輸出No,
每行輸出佔一行。 - 樣例輸入
-
2 3
- 樣例輸出
-
Yes No
#include<stdio.h>
int f[35]={0,3,7};
int prime(int x)
{
int k;
for(k=2;k<x;k++)
if(x%k==0) return 0;
return 1;
}
int main()
{
int i,j;
int m;
for(i=3;i<35;i++)
f[i]=f[i-1]+f[i-2];
while(scanf("%d",&m)&&m!=-1)//&&m!=-1和!=EOF不一樣嗎?
{
if(prime(f[m])) printf("Yes\n");
else printf("No\n");
}
return 0;
}
相關文章
- 『杭電1848』Fibonacci again and againAI
- HDU 1848 Fibonacci again and again(SG函式)AI函式
- HDU 1848 Fibonacci again and again (尼姆博弈+sg函式)AI函式
- Fibonacci
- Decade counter againAI
- 佳佳的 Fibonacci
- Fibonacci數列
- QOJ #1280.Fibonacci Partition/Fibonacci性質大雜燴
- nyoj - 1154. 找食物(簡單BFS)
- If I were a boy againAI
- Trees and XOR Queries AgainAI
- [HNU 10072] Fibonacci Number
- NYOJ 1409 快速計算【矩陣連乘】矩陣
- LeetCode之Fibonacci Number(Kotlin)LeetCodeKotlin
- A Proof of Golden Section of Fibonacci SequenceGo
- NYOJ 1427-小石子游戲【石子合併】
- WEEK5|WEB Unserialize AgainWebAI
- POI2012ROZ-Fibonacci Representation
- 驍龍480和麒麟710對比哪個效能好?驍龍480和麒麟710效能對比
- LightOJ 1038 Race to 1 Again (簡單期望)AI
- 查詢演算法__Fibonacci查詢演算法
- 藍橋嵌入式之 USART_AgainAI
- CF1982F Sorting Problem Again 題解AI
- 矽基流動 The parameter is invalid. Please check againAI
- P9825 [ICPC2020 Shanghai R] FibonacciAI
- 題解:CF633D Fibonacci-ish3D
- NYOJ 1426-大賣場購物車1【0-1揹包】
- npm install ERR Please try running this command again as root/AdministratorNPMAI
- K480N 安裝黑蘋果記錄蘋果
- 藍橋杯:入門訓練 Fibonacci數列
- LightOj1296Again Stone Game(手推SG函式)AIGAM函式
- [轉載]SystemD strikes again : Unit X.mount is bound to inactive unitAI
- 解決:ChatGPT too many requests in 1 hour.Try again laterChatGPTAI
- win10 k480鍵盤藍芽掉線怎麼連線_win10 k480鍵盤藍芽掉線解決方法Win10藍芽
- Error: Cannot retrieve metalink for repository: epel. Please verify its path and try againErrorAI
- would dispatch back to the current handler URL [/doLogin] again. Check your ViewResolver setup!AIView
- EMC CX4-480伺服器riad故障資料恢復伺服器資料恢復
- WARC:2020年全球體育贊助廣告支出480億美元
- CF1902F.Trees and XOR Queries Again-點分治、線性基AI