#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的更多相关文章

  1. HDOJ1005 数列

    Problem Description A number sequence is defined as follows:f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) ...

  2. ACM—Number Sequence(HDOJ1005)

    原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1005 主要内容: A number sequence is defined as follows: f ...

  3. Number Sequence (HDoj1005)

    Problem Description A number sequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1 ...

  4. hdoj1005(循环,找规律)

    Problem Description A number sequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1 ...

随机推荐

  1. web前端----JavaScript的BOM

    一.引入 到目前为止,我们已经学过了JavaScript的一些简单的语法.但是这些简单的语法,并没有和浏览器有任何交互. 也就是我们还不能制作一些我们经常看到的网页的一些交互,我们需要继续学习BOM和 ...

  2. MySQL笔记(四)DDL与DML风格参考

    便于 COPY ▲ 在所有操作之前: SET character_set_database=utf8; 确保 ↓ mysql> SHOW VARIABLES LIKE "%char%& ...

  3. linux查看内存free

    free 加参数-b/k//m/g,以b.k.m.g的大小显示结果,默认以k显示 [root@oldboy ~]# free total used free shared buffers cached ...

  4. ArcThemALL!5.1:解压、脱壳、压缩样样精通

    原文链接:http://www.ithome.com/html/soft/57033.htm ArcThemALL!软件主要功能: 1.支持压缩和解压功能,支持常用的7z.zip.cab.iso.ra ...

  5. ACM-ICPC 2018 南京赛区网络预赛 E AC Challenge 状压DP

    题目链接: https://nanti.jisuanke.com/t/30994 Dlsj is competing in a contest with n (0 < n \le 20)n(0& ...

  6. Unity3D学习笔记(九):摄像机

    3D数学复习 using System.Collections; using System.Collections.Generic; using UnityEngine; public class w ...

  7. 05_Flume_timestamp interceptor实践

    1.目标场景 2.Flume Agent配置 # specify agent,source,sink,channel a1.sources = r1 a1.sinks = k1 a1.channels ...

  8. Javascript库的产生和解读

    javascript库的产生,增强了浏览器或javascript语言的某些机制的功能, 让业务开发人员,更专注业务逻辑,而不是机制逻辑.   比如, 0.兼容性 同样的功能函数,不同的浏览器所暴露的a ...

  9. python 集合的比较

    setx = set(["apple", "mango"]) sety = set(["mango", "orange" ...

  10. sublime text3 (Mac) 快捷键

    符号说明 符号 说明 ⌘ command ⌃ control ⌥ option ⇧ shift ↩ enter ⌫ delete 打开/关闭/前往 快捷键 功能 ⌘⇧N 打开一个新的sublime窗口 ...