现在的位置: 首页 > 综合 > 正文

NEFU 115 斐波那契的整除

2019年04月07日 ⁄ 综合 ⁄ 共 453字 ⁄ 字号 评论关闭

题目链接:http://acm.nefu.edu.cn/JudgeOnline/problem/115.jsp

思路:找循环节,可以被3整除的Fibonacci数,n一定可以被4整除,可以被4整除的Fibonacci数,n一定可以被6整除,同样,如果Fibonacci可以被12整除,根据数论知识,知道n一定可以被12整除。

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

typedef long long LL;

LL n;

void solve()
{
	if(n % 12 == 0) printf("YES\n");
	else if(n % 4 == 0) printf("3\n");
	else if(n % 6 == 0) printf("4\n");
	else printf("NO\n");
}

int main()
{
	while(~scanf("%lld", &n))
	{
		solve();
	}
	return 0;
}

【上篇】
【下篇】

抱歉!评论已关闭.