Jzzhu has invented a kind of sequences, they meet the following property:
You are given x and y, please calculate fn modulo 1000000007 (109 + 7).
The first line contains two integers x and y (|x|, |y| ≤ 109). The second line contains a single integer n (1 ≤ n ≤ 2·109).
Output a single integer representing fn modulo 1000000007 (109 + 7).
2 33
1
0 -12
1000000006
In the first sample, f2 = f1 + f3, 3 = 2 + f3, f3 = 1.
In the second sample, f2 = - 1; - 1 modulo (109 + 7) equals (109 + 6).
----------------------------------------------------------------------------
题意就不说了,找最小循环节点,就是6
然后注意数组要从0开始,并且负数取余要让它加上一个整数(1000000007)然后再取余,就没什么了
1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <iostream> 4 #include <algorithm> 5 #include <math.h> 6 7 int main() 8 { 9 long long n,m,i,j,k,t; 10 long long str[7]; 11 while(scanf("%I64d%I64d",&n,&m)!=EOF) 12 { 13 scanf("%I64d",&t); 14 str[0]=(n+1000000007)%1000000007; 15 str[1]=(m+1000000007)%1000000007; 16 for(i=2;i<6;i++) 17 { 18 str[i]=(str[i-1]-str[i-2]);//printf("%I64d*",t%6); 19 } 20 printf("%I64d\n",(str[(t-1)%6]+1000000007)%1000000007); 21 //else 22 //printf("%I64d\n",str[t%6]%1000000007); 23 } 24 return 0; 25 }
【Unity3D】魔方
好可爱啊,油炸会不会很不错
我一脱鞋就拍上
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 软件产品开发中常见的10个问题及处理方法
· .NET 原生驾驭 AI 新基建实战系列:向量数据库的应用与畅想
· 从问题排查到源码分析:ActiveMQ消费端频繁日志刷屏的秘密
· 一次Java后端服务间歇性响应慢的问题排查记录
· dotnet 源代码生成器分析器入门
· ThreeJs-16智慧城市项目(重磅以及未来发展ai)
· .NET 原生驾驭 AI 新基建实战系列(一):向量数据库的应用与畅想
· 软件产品开发中常见的10个问题及处理方法
· Vite CVE-2025-30208 安全漏洞
· MQ 如何保证数据一致性?