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 ...
随机推荐
- 反射 方法和函数 type
1. isinstance/issubclass/type *** issubclass 判断xxx类是否是xxx类的子类 class Animal: pass class Cat(Animal): ...
- Flash 0day漏洞(CVE-2018-4878)复现
该漏洞影响 Flash Player 当前最新版本28.0.0.137以及之前的所有版本,而Adobe公司计划在当地时间2月5日紧急发布更新来修复此漏洞. 本文作者:i春秋作家——F0rmat 前言 ...
- 关于UUID
UUID是通用唯一识别码的缩写,其目的,是让分布式系统中的所有元素,都能有唯一的辨识信息. UUID是指在一台机器上生成的数字,它保证对在同一时空中的所有机器都是唯一的. 在做后台管理的时候,经常会碰 ...
- 使用Express构建RESTful API
RESTful服务 REST(Representational State Transfer)的意思是表征状态转移,它是一种基于HTTP协议的网络应用接口风格,充分利用HTTP的方法实现统一风格接口的 ...
- linux下利用dd命令测试磁盘读写速度
在Linux中,dd命令用于读取.转换和输出数据,它可从标准输入或文件中读取数据并输出到指定文件或标准输出中.该命令使用参数如下: 其中”=“后面的为设置的参数 If = <文件名> : ...
- 【原创】贡献一个项目中用到的js身份证验证-超级准!!!
前言 百度百科解释:身份证号码 首先贡献一个大神的链接:js验证身份证超准 代码 function checkIdcard(idcard) { var Errors = new Array( &quo ...
- linux解决病毒系列之一,删除十字符libudev.so病毒文件
前两天被服务器商通知服务器带宽流量增加,我想了想我们服务走的内网,没有什么大的带宽占用,于是我马上登录服务器. 用top命令查看运行情况,我擦,有一个进程吃了很高的cup,于是我赶紧用kill -9 ...
- Maven 进阶
一.Maven 版本管理 Maven 的推荐版本号约定为:主版本号.次版本号.增量版本号-<里程碑版本> 开发中的版本要以 -SNAPSHOT 结尾,因为这种快照版本是支持 jar 包被覆 ...
- 各大APP注册时发送短信验证码是怎么实现的?
第一步:获得验证码:1.找到相关的表.2.用什么发送,post,get ,ajax,当然ajax首选3.post之前要js先判断是手机号码11位,并且全部都是数字,或者用正则也行.4.用ajax发送数 ...
- (转)mysql升级5.5.20时遇到的问题:1548-Cannot load from mysql.proc. The table is probably corrupted
LINUX下将mysql从5.1升级至5.5后,发现存储过程不能用了.创建和使用存储过程时就会提示Cannot load from mysql.proc. The table is probably ...