#include <stdio.h>#include <stdlib.h>
int main(){ int num; int a,b,c,d; while(scanf("%d",&num)==1) {while(scanf("%d,%d,%d,%d",&a,&b,&c,&d)==4) {if((b-a)==(c-b)){printf("%d\n",d+(b-a));} else{printf("%d\n",d*(b/a));} } } return 0;}
while( scanf( "%d %d %d %d", &a, &b, &c, &d ) == 4 )
另外,要輸出前五項