14 条题解

  • 1
    @ 2025-11-7 1:13:23
    #include <iostream>
    using namespace std;
    int main() {
    	int t;
    	cin >> t;
    	while (t--) {
    		int N;
    		cin >> N;
    		int k = 0;
    		while ((k * k + k) / 2 < N) {
    			k++;
    		}
    		int a = k * (k - 1) / 2;
    		int b = N - a;
    		if (k % 2 == 0) {
    			cout << b << "/" << (k - b + 1) << '\n';
    		} else {
    			cout << (k - b + 1) << "/" << b << '\n';
    		}
    	}
    	return 0;
    }
    
    • @ 2025-11-7 1:14:02

      注意奇数行跟偶数行的遍历方向

信息

ID
155
时间
3000ms
内存
128MiB
难度
3
标签
(无)
递交数
417
已通过
216
上传者