#53231: 想法


kenny980721.tu@gmail.com (有事直接私)


先寫一個判斷日期合法性的副函式(下面用isVaild簡寫)

主程式判斷輸入的n的正負

如果n>0

for(int i = 4499,t = 0; t <= n; i++) {
	int x = i*i;
	if(isVaild(x)) {
	    ans = x;
	    t++;
    }
} 

如果n<0

for(int i = 4499,t = 0; t >= n; i--) {
			int x = i*i;
			if(isVaild(x)) {
			    ans = x;
			    t--;
		}
	}

最後 cout << ans;