HDU1005.规律题
来源:互联网 发布:caffe 是啥 编辑:程序博客网 时间:2024/03/28 18:09
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <cmath>
int s[100];
using namespace std;
int main()
{
int a,b,n;
while(scanf("%d%d%d",&a,&b,&n),a || b || n)
{
int i;
s[0]=s[1]=1;
for(i = 2; i<50;i++)
{
s[i] = (a*s[i-1]+b*s[i-2])%7;
if(s[i] ==1 && s[i-1] == 1)
{break;}
}
n = n%(i-1);
if( n == 0)
printf("%d\n",s[i-2]);
else
printf("%d\n",s[n-1]);
}
}
#include <stdio.h>
#include <string.h>
#include <cmath>
int s[100];
using namespace std;
int main()
{
int a,b,n;
while(scanf("%d%d%d",&a,&b,&n),a || b || n)
{
int i;
s[0]=s[1]=1;
for(i = 2; i<50;i++)
{
s[i] = (a*s[i-1]+b*s[i-2])%7;
if(s[i] ==1 && s[i-1] == 1)
{break;}
}
n = n%(i-1);
if( n == 0)
printf("%d\n",s[i-2]);
else
printf("%d\n",s[n-1]);
}
}
0 0
- HDU1005.规律题
- hdu1005(找规律题)
- HDU1005 规律题
- HDU1005 Number Sequence(规律题)
- hdu1005(规律)
- hdu1005 Number Sequence寻找规律题
- hdu1005 找规律 枚举
- hdu1005找规律
- hdu1005 Number Sequence (思维+规律)
- hdu1005 Number Sequence (找规律)
- hdu1005(大数计算可能有规律)
- HDU1005
- hdu1005
- hdu1005
- hdu1005
- HDU1005
- hdu1005
- HDU1005
- 记忆单词
- linux系统编程之进程(七):system()函数使用
- AndroidAsyncHttp 临时修复 JsonHttpResponseHandler 避免死循环
- 黑马程序员_OC基础00_基本语法
- Linux 解析thunder//:得到真实地址
- HDU1005.规律题
- VS2005+OpenCV2.3.1
- 华为历年机试试题【part4】
- pthread_cleanup_push/pop成对出现的意义
- 杭电 1870 愚人节的礼物
- 黑马程序员 复制文件夹及文件夹内文件的方法
- linux系统编程之进程(八):守护进程详解及创建,daemon()使用
- 我从跑步中领悟到了什么?
- 算法导论-递推公式-HDOJ2041