传送门codeforce1447A
大致意思:n个数分别为1 、 2 、 3… n 1、2、3…n1、2、3…n,现在有一种操作,第j 次操作能让除开被操作数的其他所有数都加上j 。如果最后n 个数相等,输出需要几次操作,与每次被操作的数的下标。
思路:要让所有的数相等,那么让相等时所有的数都等于1 到n 的和,对于第一个数 他已经有一个1 ,那么就对除开它本身的所有数加上1 ,对第二个数,它现在是2 + 1 ,其他的数少了一个2 ,那么就对除开它本身的所有数加上2 …以此类推,加到最后都是1 到n 的和
如:→Judgement Protocol
Test: #1, time: 15 ms., memory: 4 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
2
2
3
Output
2
1 2
3
1 2 3
Answer
2
1 2
3
1 2 3
#include <bits/stdc++.h>
using namespace std;
int t, n;
int main() {
cin >> t;
while(t--) {
cin >> n;
cout << n <<endl;
for(int i = 1; i <= n; ++i)
cout << i << " ";
cout <<endl;
}
}