1047A_Little C Loves 3 I(构造)

Posted lllaih

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了1047A_Little C Loves 3 I(构造)相关的知识,希望对你有一定的参考价值。

A. Little C Loves 3 I
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Little C loves number «3» very much. He loves all things about it.

Now he has a positive integer nn. He wants to split nn into 33 positive integers a,b,ca,b,c, such that a+b+c=na+b+c=n and none of the 33 integers is a multiple of 33. Help him to find a solution.

Input

A single line containing one integer nn (3n1093≤n≤109) — the integer Little C has.

Output

Print 33 positive integers a,b,ca,b,c in a single line, such that a+b+c=na+b+c=n and none of them is a multiple of 33.

It can be proved that there is at least one solution. If there are multiple solutions, print any of them.

Examples
input
Copy
3
output
Copy
1 1 1
input
Copy
233
output
Copy
77 77 79
被样例困惑了很久,看了题解啧啧,其实这题就是构造
大致题意:给你一个数n,找到三个数a,b,c,使得a+b+c=n,并且a,b,c都不能是3的倍数
分析:当n%3=0时,n-2一定不是3的倍数,可以构造为a=1,b=1,c=n-2;当n%3!=0时,n-3一定不是3的倍数,那么可以构造为,a=1,b=2,c=n-3.注意这个构造是任意的,只要满足条件即可
 1 #include<cstdio>
 2 #include<cstring>
 3 #include<algorithm>
 4 using namespace std;
 5 int main()
 6 {
 7     int n;
 8     while(~scanf("%d",&n))
 9     {
10         if(n%3==0)
11             printf("1 1 %d
",n-2);
12         else
13             printf("1 2 %d
",n-3);
14     }
15     return 0;
16 }

 



以上是关于1047A_Little C Loves 3 I(构造)的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces Round #511 Div2 D. Little C Loves 3 II

A. Little C Loves 3 I Codeforces Round #511 (Div. 2) 数学

[P1580] yyy loves Easter_Egg I

2021牛客多校训练7 I xay loves or

luogu 1047

[CodeForces - 447C] C - DZY Loves Sequences