0
点赞
收藏
分享

微信扫一扫

A. Add Candies(思维)Codeforces Round #683 (Div. 2, by Meet IT)

原题链接: ​​http://codeforces.com/contest/1447/problem/A​​

A. Add Candies(思维)Codeforces Round #683 (Div. 2, by Meet IT)_i++
测试样例

input
2
2
3
output
1
2
5
3 3 3 1 2

Note

In the first case, adding 1 candy to all bags except of the second one leads to the arrangement with [2,2] candies.

In the second case, firstly you use first three operations to add 1+2+3=6 candies in total to each bag except of the third one, which gives you [7,8,3]. Later, you add 4 candies to second and third bag, so you have [7,12,7], and 5 candies to first and third bag — and the result is [12,12,12].

题意: 你有A. Add Candies(思维)Codeforces Round #683 (Div. 2, by Meet IT)_c代码_02个包,第A. Add Candies(思维)Codeforces Round #683 (Div. 2, by Meet IT)_i++_03个包中有A. Add Candies(思维)Codeforces Round #683 (Div. 2, by Meet IT)_i++_03个糖果,现在你可以进行A. Add Candies(思维)Codeforces Round #683 (Div. 2, by Meet IT)_#define_05个操作,其中第A. Add Candies(思维)Codeforces Round #683 (Div. 2, by Meet IT)_i++_03个操作表述为选择一个包,使得除这个包之外所有的包中的糖果都加上A. Add Candies(思维)Codeforces Round #683 (Div. 2, by Meet IT)_c代码_07个糖果,现在你需要使得每个包中的糖果都相同。(不必在乎A. Add Candies(思维)Codeforces Round #683 (Div. 2, by Meet IT)_#define_05个大小)

解题思路: 这是一道思维题,也相当于找规律的题,不要被样例迷惑了。我们发现,如果我们进行A. Add Candies(思维)Codeforces Round #683 (Div. 2, by Meet IT)_c代码_09个操作,其中在第A. Add Candies(思维)Codeforces Round #683 (Div. 2, by Meet IT)_c代码_10个操作中刚好选择第A. Add Candies(思维)Codeforces Round #683 (Div. 2, by Meet IT)_c代码_10个包,那么最后所有的包的糖果都是A. Add Candies(思维)Codeforces Round #683 (Div. 2, by Meet IT)_#define_12个,都是相等的。 这即是正确答案。

AC代码

/*

*
*/
#include<bits/stdc++.h>//POJ不支持

#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=a;i>=n;i--)

using namespace std;

const int inf=0x3f3f3f3f;//无穷大。
const int maxn=1e5;//限定值。
typedef long long ll;

int t,n;
int main(){
while(cin>>t){
while(t--){
cin>>n;
cout<<n<<endl;
rep(i,1,n){
cout<<i<<" ";
}
cout<<endl;
}
}
return 0;
}


举报

相关推荐

0 条评论