C

YONAGI 发表于 6天前 · 关联问题 一鸣师姐种田

include<stdio.h>

int main(){

int n=0,x=0,y=0; long int sum=0,i=0; scanf("%d",&n); while(n--){ scanf("%d %d",&x,&y); int max=x>y?x:y; int min=x+y-max; for(i=max*min;i>0;i=max*min){ sum+=4*(min<max?min:max); if(max>min) max-=min; else if(max<min) min-=max; else max=0,min=0; } printf("%ld\n",sum); sum=0; }

}