Number Sequence (HDoj1005)
f(1) =
1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7.
Given A, B, and
n, you are to calculate the value of f(n).
case contains 3 integers A, B and n on a single line (1 <= A, B <= 1000, 1
<= n <= 100,000,000). Three zeros signal the end of input and this test
case is not to be processed.
line.
#include<stdio.h>
#include<math.h>
int f(int a,int b,int n)
{
if(n==)
return ;
if(n==)
return ;
return (a*f(a,b,n-)+b*f(a,b,n-))%;
}
int main()
{
int a,b;
int n;
while(scanf("%d%d%d",&a,&b,&n)==)
{
if(a==b&&b==n&&n==)
break;
else
printf("%d\n",f(a,b,n%));
}
}
Number Sequence (HDoj1005)的更多相关文章
- ACM—Number Sequence(HDOJ1005)
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1005 主要内容: A number sequence is defined as follows: f ...
- HDU 1711 Number Sequence(数列)
HDU 1711 Number Sequence(数列) Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Ja ...
- HDU 1005 Number Sequence(数列)
HDU 1005 Number Sequence(数列) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Jav ...
- Number Sequence(hdu4390)
Number Sequence Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tot ...
- HDU 1711 Number Sequence(KMP)附带KMP的详解
题目代号:HDU 1711 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1711 Number Sequence Time Limit: 10000/ ...
- Number Sequence(kmp)
Number Sequence Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- 1005 Number Sequence(HDU)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1005 Number Sequence Time Limit: 2000/1000 MS (Java/O ...
- POJ - 1019 Number Sequence (思维)
https://vjudge.net/problem/POJ-1019 题意 给一串1 12 123 1234 12345 123456 1234567 12345678 123456789 1234 ...
- HDU 1005 Number Sequence (模拟)
题目链接 Problem Description A number sequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (A * f( ...
随机推荐
- EditText判断用户输入完成,然后进行操作解决方案
private Timer timer = new Timer(); private final long DELAY = 1000; // in ms EditText editTextStop = ...
- 异常处理与调试4 - 零基础入门学习Delphi53
调试(Debug) 让编程改变世界 Change the world by program 调试(Debug) 在应用程序开发中检测.处理程序中的错误是一个非常重要的环节.在Delphi的集成开发环境 ...
- mysql null值转换
1.如果为空返回0 select ifnull(null,0) 2.如果为空返回0,否则返回1 select if(isnull(col),0,1) as col.
- ViewBag、ViewData和TempData使用方法、区别与联系
一.区别与联系 ViewData 和 TempData 都可以传递弱类型数据,区别如下:TempData 只在当前 Action 中有效,生命周期和 View 相同:保存在Session中,Contr ...
- CSS之Hack
一.类内部Hack IE都能识别*;标准浏览器(如FF)不能识别*:IE6能识别*,但不能识别 !important, IE7能识别*,也能识别!important; FF不能识别*,但能识别!imp ...
- Linux系统编程(18)——正则表达式实用举例
匹配特定字符串: 只能输入长度为3的字符:"^.{3}$". 只能输入由26个英文字母组成的字符串:"^[A-Za-z]+$". 只能输入由26个大写英文字母组 ...
- Contains Duplicate II 解答
Question Given an array of integers and an integer k, find out whether there are two distinct indice ...
- Kth Largest Element in an Array 解答
Question Find the kth largest element in an unsorted array. Note that it is the kth largest element ...
- ORACLE 中写入txt文本与从Txt文件中读入数据 修改表结构
--创建一个表 DROP TABLE TEST CASCADE CONSTRAINTS ; CREATE TABLE TEST(A VARCHAR(30),B VARCHAR(30)); --查看具体 ...
- Xshell不能连接SSH的解决
异常处理汇总-服 务 器 http://www.cnblogs.com/dunitian/p/4522983.html 重新启动看看:/etc/init.d/ssh restart (/etc/ini ...