HBMY=1875: A sequence of numbers
来源:互联网 发布:unity3d下载安装教程 编辑:程序博客网 时间:2024/06/03 18:02
1875: A sequence of numbers
Total Submissions: 9 Accepted: 3
[Submit] [Statistic] [discuss] [Go Back]
题目描述
Xinlv wrote some sequences on the paper a long time ago, they might be arithmetic or geometric sequences. The numbers are not very clear now, and only the first three numbers of each sequence are recognizable. Xinlv wants to know some numbers in these sequences, and he needs your help.
输入描述
The first line contains an integer N, indicting that there are N sequences. Each of the following N lines contain four integers. The first three indicating the first three numbers of the sequence, and the last one is K, indicating that we want to know the K-th numbers of the sequence.
You can assume 0 < K <= 10^9, and the other three numbers are in the range [0, 2^63). All the numbers of the sequences are integers. And the sequences are non-decreasing.
输出描述
Output one line for each test case, that is, the K-th number module (%) 200907.
输入样例
21 3 5 82 4 8 7
输出样例
15128
提示
来源or类型
入门题-数学
AC 代码:
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
long long T;
long long a,b,c,d,i;
cin>>T;
while(T--)
{
cin>>a>>b>>c>>d;
if(a==b && b==c )
{
cout<<a%200907<<endl;
continue;
}
if(b-a==c-b)
{
long long s=b-a;
cout<<a%200907+((((d-1)%200907)*(s%200907))%200907)%200907<<endl;
}
else
{
long long l=(b/a)%200907;
long long temp=1;
d--;
a=a%200907;
while(d) //关键的地方,才开始因为没有想到这里,直接用的是for语句,不是WA,就是超时,然后换这个思路才AC,现在还是不明白为什么for不行,很尴尬的;
{
if(d%2==1)
{
temp=temp*l;
temp%=200907;
}
l=(l*l)%200907;
d/=2;
}
long long sum=(a*temp)%200907;
cout<<sum<<endl;
}
}
return 0;
}
- HBMY=1875: A sequence of numbers
- A sequence of numbers
- A sequence of numbers
- A sequence of numbers
- HDOJ A sequence of numbers
- A Sequence of Numbers HDU
- hdu2817 A sequence of numbers
- 3293. A Sequence of Numbers
- hdu2817 A sequence of numbers
- HDU2817 A sequence of numbers
- A Sequence of Numbers (dp)
- hdu2817 A sequence of numbers
- 题目58:A sequence of numbers
- hdu 2817 A sequence of numbers
- HDU 2817 A sequence of numbers
- hdu(2817)A sequence of numbers
- 题目1442:A sequence of numbers
- HDU2817:A sequence of numbers(快速幂取模)
- 在全志A64平台点亮GC2145 V1.0(分色排版)录像有问题
- matlab下 enframe分帧函数不可用
- 【实用手记】树莓派旋转屏幕
- 大数据的学习计划
- 读取msi文件内容
- HBMY=1875: A sequence of numbers
- 计蒜客蓝桥杯模拟赛5 引爆炸弹
- UEditor(百度编辑器)的使用
- 杂记
- Kotlin基本使用-类的声明
- 修改Eclipse所有文件的编码格式为UTF-8
- 转--【工具使用】IntelliJ IDEA 2017 搭建spring mvc
- spring bean加载--从缓存中获取beanspring bean加载--从缓存中获取bean【转】
- 【RecycleView加分割线】Android RecycleView列表布局添加分割线如此简单