HDOJ1005
#include "iostream"
using namespace std; int fun(int A,int B,int n)
{
int x = ,y = ,z;
if (n == || n == )
return ;
else
{
z = (A*y +B*x )%;
for(int i=;i<n;i++)
{
int t = z;
z = (A*z +B*y )%;
x = y;
y = t;
}
return y;
} } int main()
{
int A,B,n;
int a[];
int i = ;
cin >> A >> B >> n;
while(A != ||B != ||n != )
{
a[i] = fun(A,B,n%);
i++;
cin >> A >> B >> n;
}
for(int j=;j<i;j++)
{
cout << a[j] <<"\n";
}
}
第一次交的时候时间超了,然后知道还有循环一说。
HDOJ1005的更多相关文章
- HDOJ1005 数列
Problem Description A number sequence is defined as follows:f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) ...
- ACM—Number Sequence(HDOJ1005)
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1005 主要内容: A number sequence is defined as follows: f ...
- Number Sequence (HDoj1005)
Problem Description A number sequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1 ...
- hdoj1005(循环,找规律)
Problem Description A number sequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1 ...
随机推荐
- sql server deadlock跟踪的四种方法
最近写程序常会遇到deadlock victim,每次一脸懵逼.研究了下怎么跟踪,写下来记录下. 建测试数据 CREATE DATABASE testdb; GO USE testdb; CREATE ...
- oracle用户名和密码到期后如何处理
原因:确定是由于Oracle11g中默认在default概要文件中设置了“PASSWORD_LIFE_TIME=180天”所导致. 影响: 1.密码过期后,业务进程连接数据库异常,影响业务使用. 2. ...
- web前端----响应式布局
响应式开发 为什么要进行响应式开发? 随着移动设备的流行,网页设计必须要考虑到移动端的设计.同一个网站为了兼容PC端和移动端显示,就需要进行响应式开发. 什么是响应式? 利用媒体查询,让同一个网站兼容 ...
- Putty Technical Note
转载自:http://libai.math.ncu.edu.tw/bcc16/6/putty/puttyt.html Terminal panel Terminal 面板可調整 PuTTY 對於模擬終 ...
- Redis 如何保持和MySQL数据一致【二】
需求起因 在高并发的业务场景下,数据库大多数情况都是用户并发访问最薄弱的环节.所以,就需要使用redis做一个缓冲操作,让请求先访问到redis,而不是直接访问MySQL等数据库. 这个业务场景,主要 ...
- xShell终端中文乱码完全解决方法
xShell终端中文乱码完全解决方法 xShell(xShell5)以及其他终端中文乱码的原因无非有三种:(1)Linux系统的编码问题:(2)xShell终端的编码问题: (3)两端的语言编码不一致 ...
- Linux 环境 HTTP 服务器
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <netinet/in ...
- 格式化输出%与format
一.%的用法 1.1整数输出 %o —— oct 八进制 : %d —— dec 十进制 : %x —— hex 十六进制 >>> print('%o' % 20) 24 >& ...
- aws相关文档
使用 IAM 角色授予对 Amazon EC2 上的 AWS 资源的访问权 https://docs.aws.amazon.com/zh_cn/sdk-for-java/v1/developer-gu ...
- StringUtils类常用的方法讲解
StringUtils 方法的操作对象是 Java.lang.String 类型的对象,是 JDK 提供的 String 类型操作方法的补充,并且是 null 安全的(即如果输入参数 String 为 ...