引用
1006 - Hex-a-bonacci
PDF (English) Statistics Forum
Time Limit: 0.5 second(s) Memory Limit: 32 MB
Given a code (not optimized), and necessary inputs, you have to find the output of the code for the inputs. The code is as follows:
int a, b, c, d, e, f;
int fn( int n ) {
if( n == 0 ) return a;
if( n == 1 ) return b;
if( n == 2 ) return c;
if( n == 3 ) return d;
if( n == 4 ) return e;
if( n == 5 ) return f;
return( fn(n-1) + fn(n-2) + fn(n-3) + fn(n-4) + fn(n-5) + fn(n-6) );
}
int main() {
int n, caseno = 0, cases;
scanf("%d", &cases);
while( cases-- ) {
scanf("%d %d %d %d %d %d %d", &a, &b, &c, &d, &e, &f, &n);
printf("Case %d: %d\n", ++caseno, fn(n) % 10000007);
}
return 0;
}
Input
Input starts with an integer T (≤ 100), denoting the number of test cases.
Each case contains seven integers, a, b, c, d, e, f and n. All integers will be non-negative and 0 ≤ n ≤ 10000 and the each of the others will be fit into a 32-bit integer.
Output
For each case, print the output of the given code. The given code may have integer overflow problem in the compiler, so be careful.
Sample Input
Output for Sample Input
5
0 1 2 3 4 5 20
3 2 1 5 0 1 9
4 12 9 4 5 6 15
9 8 7 6 5 4 3
3 4 3 2 54 5 4
Case 1: 216339
Case 2: 79
Case 3: 16636
Case 4: 6
Case 5: 54
#include <stdio.h>
#include <stdlib.h>
int a, b, c, d, e, f, aaa[10005];
int fn( int n ) {
if( n == 0 ) return a;
if( n == 1 ) return b;
if( n == 2 ) return c;
if( n == 3 ) return d;
if( n == 4 ) return e;
if( n == 5 ) return f;
return( aaa[n-1] + aaa[n-2] + aaa[n-3] + aaa[n-4] + aaa[n-5] + aaa[n-6] );
}
int main() {
int i,n, caseno = 0, cases;
scanf("%d", &cases);
while( cases-- ) {
scanf("%d %d %d %d %d %d %d", &a, &b, &c, &d, &e, &f, &n);
for(i=0;i<n+3;i++)
{
aaa[i] = fn(i);
if(aaa[i]>10000007) aaa[i] %= 10000007;
}
printf("Case %d: %d\n", ++caseno, aaa[n] % 10000007);
}
return 0;
}
分享到:
相关推荐
PMW-HEX-V1.9 V2.4正式版,没有功能限制,想用就用哦
pwm转hex 单片机51程序软件网上下的。请放心使用。本人没用过。keil的软件还有win,hex 的软件,安装了打开挺好的。可惜是试用版有需要的联系哦哟啊哦
三菱PMWtoHEX软件是一款由三菱软件写好梯形图再运行转换的软件,该软件界面简洁,操作方便,用户只需设定好51单片机的输入输出,打开写好的梯形图,转换出的就是hex文件,烧录到51单片机,就可以执行编写的PLC程序。
网上下了N个 从1.6到2.8版本,没有一个能注册,还有2.8版本都是他妈的骗子 说是破解 下来都没有一个能用的 全都是25步限制,现在想想都来火!...这个是PMW-HEX-1.9破解版 我找许久的最好的破解版!
用PMW-HEX设置好IO点对应X Y点关系(注意字符大写,没有定义的X Y点不能在梯形图中出现,否则转换失败),保存设置; 打开PMW,就开始转换了(软件转换时间比较长,耐心等待,以时间换取生成代码的小空间); 转换...
用PMW-HEX设置好IO点对应X Y点关系. 转换成hex文件,下载到51单片机. 此文件夹不可以放在桌面上,文件夹不能用中文名,名字间不能有空格。 如果你的操作系统隐藏了文件的扩展名,请打开,不然找不到生成的FX1N.HEX这...
pmw-hex 完美破解 没有步数限制 轻松完成转换
scratch-gui在npm安装过程中出现下载不到scratch-hex文件的问题解决方案
开源项目-Code-Hex-pget.zip,在Go中并行下载
单片机plc PMW-HEX-V2.8转换软件破解版 好不容易才找到 带注册机
使用这个软件后就可以用单片机替代PLC了。
此软件无需安装打开能用,本人以见弄好注册的,无限制转换步数。
NULL 博文链接:https://yangchenglinkd.iteye.com/blog/1736212
支持三菱基本指令,支持的功能指令有:ZRN PLSY PLSR ALT MOV ZRST INC DEC ADD SUB MUL DIV以及它们的32位指令 支持单片机系列有:STC12C54/56 STC89C51/52 STC89C54/55/58 STC11/10/12C5A/12C52 ...
内包含有一份代码,ASCII-to-HEX labview代码,保证无错
直接建立hex文件,使用51单片机指令对应的机器码操作点亮LED或者其它,手动计算校验和比较麻烦,我们可以采用软件,直接计算出校验和
hex-editor当你使用比如compare等文件编辑器不能打开大容量(比如大于4GB)的十六进制文件时,来用这个软件 让你瞬间打开,不卡!不卡!不卡!!!迅速打开欧。
支持WIN7系统 把三菱的梯形图程序直接转换成hex文件,下载到51单片机
开源项目-Code-Hex-retrygroup.zip,GitHub - Code-Hex/retrygroup
522RC-hex文件