題意:在n*n的上從左下角開始,每次走n+1個點畫一個叉,問回到起點時一共畫幾個叉;
思路:gcd;
#include#include #include #include using namespace std; long long n,m,num,t,a,b,r; int i,j,k,rcount,shu,flag,yu,len; long long gcd(long long a,long long b) { long long c; c=a%b; while(c) { a=b; b=c; c=a%b; } return b; } int main() { while(cin>>t) { while(t--) { cin>>n; a=4*n,b=n+1; num=4*n/gcd(a,b)+1; cout<