poj 1658 Eva's Problem

简介:

确实是非常水的题,在这里留个痕迹

AC的代码:

#include<stdio.h>

int main()
{
	int n;
	scanf("%d",&n);

	int a[6],i;
	int gap;
	int result;

	while(n--)
	{
		for (i=1;i<=4;i++)
			scanf("%d",&a[i]);

		//等差更容易判断,如果不是等差就一定是等比
		gap=a[2]-a[1];
		if (gap==a[3]-a[2])
		{
			//是等差数列
			result=a[4]+gap;
		}

		else
		{
			//等比数列
			result=a[4]*a[2]/a[1];
		}

		for(i=1;i<=4;i++)
			printf("%d ",a[i]);

		printf("%d\n",result);
	}
		
	return 0;
}


相关文章
|
C++
【PAT甲级 - C++题解】1108 Finding Average
【PAT甲级 - C++题解】1108 Finding Average
73 0
AtCoder Beginner Contest 226 E - Just one(dfs求连通块 组合数学)
AtCoder Beginner Contest 226 E - Just one(dfs求连通块 组合数学)
105 0
AtCoder Beginner Contest 133 E - Virus Tree 2(组合数学)
AtCoder Beginner Contest 133 E - Virus Tree 2(组合数学)
104 0
|
机器学习/深度学习
AtCoder Beginner Contest 218 F - Blocked Roads (最短路径还原 思维)
AtCoder Beginner Contest 218 F - Blocked Roads (最短路径还原 思维)
99 0
AtCoder Beginner Contest 221 D - Online games(差分 离散化 区间)
AtCoder Beginner Contest 221 D - Online games(差分 离散化 区间)
132 0
CodeForces 1195C Basketball Exercise (线性DP)
CodeForces 1195C Basketball Exercise (线性DP)
119 0
HDU-1017,A Mathematical Curiosity
HDU-1017,A Mathematical Curiosity
|
物联网 Go C++
洛谷【2】P1001 A+B Problem
洛谷【2】P1001 A+B Problem