Skip to content

Instantly share code, notes, and snippets.

@cthbst
Last active May 8, 2016 02:24
Show Gist options
  • Save cthbst/6574934ebe42c0b0e943358debe9ab33 to your computer and use it in GitHub Desktop.
Save cthbst/6574934ebe42c0b0e943358debe9ab33 to your computer and use it in GitHub Desktop.
#include<iostream>
using namespace std ;
int main(){
int Tasks ;
int a[5] ;
cin >> Tasks ;
while (Tasks--){
//input -------------
for (int i=0 ;i<4 ;i++ )
cin >> a[i] ;
//solve -------------
if (a[1]-a[0]==a[2]-a[1]) // 等差數列
a[4]=a[3]*2-a[2] ;
else // 等比數列
a[4]=a[3]*a[3]/a[2] ;
//output ------------
for (int i=0 ;i<4 ;i++ )
cout << a[i] << " " ;
cout << a[4] << endl ;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment