HDU6198
number number number
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 118 Accepted Submission(s): 79
Problem Description
⋅ F0=0,F1=1;
⋅ Fn=Fn−1+Fn−2 (n≥2).
Give you an integer k, if a positive number n can be expressed by
n=Fa1+Fa2+...+Fak where 0≤a1≤a2≤⋯≤ak, this positive number is mjf−good. Otherwise, this positive number is mjf−bad.
Now, give you an integer k, you task is to find the minimal positive mjf−bad number.
The answer may be too large. Please print the answer modulo 998244353.
Input
Each test case includes an integer k which is described above. (1≤k≤109)
Output
Sample Input
Sample Output
Source
//2017-09-10
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
#define MAXN 100 using namespace std; const int MOD = ; struct Matrix
{
LL a[MAXN][MAXN];
int r, c;
}; Matrix ori, res; void init()
{
memset(res.a, , sizeof(res.a));
res.r = ; res.c = ;
for(int i = ; i <= ; i++)
res.a[i][i] = ;
ori.r = ; ori.c = ;
ori.a[][] = ori.a[][] = ori.a[][] = ;
ori.a[][] = ;
} Matrix multi(Matrix x, Matrix y)
{
Matrix z;
memset(z.a, , sizeof(z.a));
z.r = x.r, z.c = y.c;
for(int i = ; i <= x.r; i++)
{
for(int k = ; k <= x.c; k++)
{
if(x.a[i][k] == ) continue;
for(int j = ; j<= y.c; j++)
z.a[i][j] = (z.a[i][j] + (x.a[i][k] * y.a[k][j]) % MOD) % MOD;
}
}
return z;
}
void Matrix_mod(int n)
{
while(n)
{
if(n & )
res = multi(ori, res);
ori = multi(ori, ori);
n >>= ;
}
printf("%lld\n", res.a[][]- % MOD);
} int main()
{
int k;
while(scanf("%d", &k) != EOF)
{
init();
k++;
Matrix_mod(*k+);
}
return ;
}
HDU6198的更多相关文章
- [HDU6198]number number number
题目大意: 给定一个数k表示你可以从包括0的斐波那契数列中任取k个数,得到它们的和.求最小的不能得到的自然数. 思路: 打表找规律,可以发现答案为f(2k+3)-1,然后用公式f(i)=f(i/2)* ...
- hdu6198 number number number(递推公式黑科技)
number number number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
随机推荐
- Django(ORM查询1)
day69 参考:http://www.cnblogs.com/liwenzhou/p/8660826.html 在Python脚本中调用Django环境 orm1.py import os if _ ...
- maven build的常用生命周期
常用的maven build goals: validate - validate the project is correct and all necessary information is av ...
- flask开发的CMS管理系统
Dohoom 详细介绍 Dohoom 基于Python3 Flask +Mysql+ Redis开发的一个Web系统 可用于搭建(开发)个人网站, 企业官网.包含:相册模块,文章模块,小组模块,私信模 ...
- odoo开发笔记 -- 异常信息处理汇总
1 Traceback (most recent call last): File , in _handle_exception return super(JsonRequest, self)._ha ...
- C#简单操作MongoDB
一 安装MongoDB 官网按需下载, 安装, 一步到位. 二 VS创建新项目 创建一个.netcore console项目, 然后nuget安装驱动MongoDB.Driver 三 建立连接 在Pr ...
- python解析json数据
现在的API接口多为xml或json,json解析更简洁相对xml来说 以豆瓣的API接口为例,解析返回的json数据: https://api.douban.com/v2/book/1220562 ...
- linux free命令详解(一)
一. 作用 free命令可以显示当前系统未使用的和已使用的内存数目,还可以显示被内核使用的内存缓冲区. 二. 语法 free [选项] 三. 选项 默认情况下,即在没有选项的情况下,&qu ...
- Postman入门之Mock测试
1.什么是Mock测试: mock测试就是在测试过程中,对于某些不容易构造或者不容易获取的对象,用一个虚拟的对象来创建以便测试的测试方法. 2.添加要Mock测试的接口为example: 2.1点击r ...
- 客户端禁用cookie
如果客户端禁用cookie的话不影响session使用 的设置方法: <sessionState cookieless="AutoDetect"
- SpringBoot开发使用@ImportResource注解影响拦截器
问题描述 今天在给SpringBoot项目配置拦截器的时候发现怎么都进不到拦截器的方法里面,在搜索引擎上看了无数篇关于配置拦截器的文章都没有找到解决方案. 就在我准备放弃的时候,在 CSDN 上发现了 ...