#24056: 爛!


goodspeed (王宥翔)

學校 : 臺北市私立延平高級中學
編號 : 103387
來源 : [123.192.201.25]
最後登入時間 :
2024-04-25 16:42:06
e128. 新北100-1貪食蛇 -- 北縣新北北三區100年資訊學科能力競賽 | From: [123.193.51.170] | 發表日期 : 2021-01-13 20:49

宏唯爛

#include<iostream>

#include<cmath>

using namespace std;

 

int main() {

int n;

while (cin >> n, n != 0) {

int x = sqrt(n);

int step = n - x*x;

if (x % 2 == 0) {

if (step == 0) cout << x << " 1" << endl;

else if (step <= x+1) cout << x+1 << " " << step << endl;

else cout << x+x+2-step << " " << x+1 << endl; 

} else {

if (step == 0) cout << "1 " << x << endl;

else if (step <= x+1) cout << step << " " << x+1 << endl;

else cout << x+1 << " " << x+x+2-step << endl; 

}

}

}

 

 
ZeroJudge Forum