【九度】题目1442:A sequence of numbers
来源:互联网 发布:mysql 视频 编辑:程序博客网 时间:2024/05/14 16:54
- 题目描述:
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 2 3 51 2 4 5
- 样例输出:
5
16
// arithmetic or geometric sequences.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"struct e{ long a; long b; long c; long th;}buf[5];int _tmain(int argc, _TCHAR* argv[]){ int n; while (scanf("%d",&n)){for (int i = 0; i < n; i++){scanf("%ld%ld%ld%ld",&buf[i].a,&buf[i].b,&buf[i].c,&buf[i].th);}for (int i = 0; i < n; i++){if (buf[i].b-buf[i].a==buf[i].c-buf[i].b)//是等差{ long ans=buf[i].a+(buf[i].th-1)*(buf[i].b-buf[i].a);printf("%ld\n",ans%200907);}else{ long a=buf[i].b/buf[i].a; long ans=1; long b=buf[i].th-1; while (b) //!!!二分求幂!!!{if(b%2) ans*=a; b/=2;a*=a;}printf("%ld",ans*a%200907);}}}return 0;}
- 【九度】题目1442:A sequence of numbers
- 九度OJ题目1442:A sequence of numbers
- 题目1442:A sequence of numbers 九度OJ
- 九度 题目1442:A sequence of numbers
- 九度题目1442:A sequence of numbers
- 【九度OJ】题目1442:A sequence of numbers 解题报告
- 题目1442:A sequence of numbers
- 题目1442:A sequence of numbers
- 58-题目1442:A sequence of numbers
- 题目1442:A sequence of numbers
- 题目1442:A sequence of numbers
- 九度OJ 1442 A sequence of numbers
- 九度OJ-1442:A sequence of numbers
- 九度OJ 1442 A sequence of numbers
- 题目58:A sequence of numbers
- A sequence of numbers
- A sequence of numbers
- A sequence of numbers
- Linux驱动之I2C总线驱动开发
- 学密码学一定得学程序
- 二维码QR Code简介及其解码实现(zxing-cpp)
- startup
- 0-1分布(伯努利分布)、n 重伯努利分布(二项分布)
- 【九度】题目1442:A sequence of numbers
- 啊哈,算法学习笔记(1)
- dubbo使用记录
- 数据结构顺序表应用5:有序顺序表归并
- [读书笔记] 重构改善既有代码的设计(1)
- 计算机网络之网络层(划分子网和构造超网)
- 数值分解
- 437. Path Sum III*
- uva10163(两次dp)