CF1047A Little C Loves 3 I

本文提供了一种解决CodeForces平台A题的有效算法。题目要求将一个正整数n分成三个非3的倍数的正整数之和。文章详细介绍了如何根据不同情况选择合适的数字组合,以满足题目要求。对于n模3等于0的情况,输出1,1,n-2;否则输出1,2,n-3。这是一种简洁而高效的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

Little C Loves 3 I

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

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

Input

A single line containing one integer n ( 3 ≤ n ≤ 1 0 9 ) n (3≤n≤10^9) n(3n109) — the integer Little C has.

Output

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

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

Examples
input

3

output

1 1 1

input

233

output

77 77 79

题解

如果 n   m o d   3 = 0 n\ mod\ 3=0 n mod 3=0输出 1 , 1 , n − 2 1,1,n-2 1,1,n2,否则输出 1 , 2 , n − 3 1,2,n-3 1,2,n3

代码
#include<bits/stdc++.h>
using namespace std;
int n;
void in(){scanf("%d",&n);}
void ac(){n%3?printf("1 2 %d",n-3):printf("1 1 %d",n-2);}
int main(){in();ac();}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ShadyPi

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值