CodeForces - 1047A
A. Little C Loves 3 I
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
Little C loves number «3» very much. He loves all things about it.
Now he has a positive integer n. He wants to split n into 3 positive integers a,b,c, such that a+b+c=n and none of the 3 integers is a multiple of 3. Help him to find a solution.
Input
A single line containing one integer n (3≤n≤109) — the integer Little C has.
Output
Print 3 positive integers a,b,c in a single line, such that a+b+c=n and none of them is a multiple of 3.
It can be proved that there is at least one solution. If there are multiple solutions, print any of them.
Examples
inputCopy
3
outputCopy
1 1 1
inputCopy
233
outputCopy
77 77 79
签到题,读遍题,就能过!
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int a;
a=n/3;
if(a%3==0){ if(n%3==0) cout<<a-2<<' '<<a+1<<' '<<a+1;
else if(n%3==1) cout<<a-1<<' '<<a+1<<' '<<a+1;
else cout<<a-1<<' '<<a+1<<' '<<a+2;}
if(a%3==1){
if(n%3==0) cout<<a<<' '<<a<<' '<<a;
if(n%3==1) cout<<a<<' '<<a<<' '<<a+1;
if(n%3==2) cout<<a+1<<' '<<a+1<<' '<<a;
}
if(a%3==2)
{
if(n%3==0) cout<<a<<' '<<a<<' '<<a;
if(n%3==1) cout<<a-1<<' '<<a+2<<' '<<a;
if(n%3==2) cout<<a<<' '<<a<<' '<<a+2;
}
return 0;
}
CodeForces - 1047A的更多相关文章
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
- CodeForces - 261B Maxim and Restaurant
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...
- CodeForces - 696B Puzzles
http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...
- CodeForces - 148D Bag of mice
http://codeforces.com/problemset/problem/148/D 题目大意: 原来袋子里有w只白鼠和b只黑鼠 龙和王妃轮流从袋子里抓老鼠.谁先抓到白色老鼠谁就赢. 王妃每次 ...
随机推荐
- django rest framework用户认证
django rest framework用户认证 进入rest framework的Apiview @classmethod def as_view(cls, **initkwargs): &quo ...
- MTK Androiod HAL如何向上层提供接口
Android中HAL如何向上层提供接口总结 转自:http://blog.csdn.net/flydream0/article/details/7086273 参考文献: http://blog.c ...
- Java 给 PowerPoint 文档添加背景颜色和背景图片
在制作Powerpoint文档时,背景是非常重要的,统一的背景能让Powerpoint 演示文稿看起来更加干净美观.本文将详细讲述如何在Java应用程序中使用免费的Free Spire.Present ...
- go 接口与动态类型
Go 没有类:数据(结构体或更一般的类型)和方法是一种松耦合的正交关系. 二.动态方法调用 通常需要编译器静态检查的支持:当变量被赋值给一个接口类型的变量时,编译器会检查其是否实现了该接口的所有函数.
- go For-range结构
For结构: for 初始化;条件语句;修饰语句{ 输出 } 一.For-range结构是可以怎么用? 这种构建方法可以应用于数组和切片: for ix, value := range slice1 ...
- 29.1 collection层次结构 中的根接口
/* * Collection * boolean add(E e) * void clear() * boolean contains(Object o) * boolean isEmpty() * ...
- 21 static 静态的使用及特点
/* * static:他是一个关键字,用来修饰成员变量和成员方法 * static特点: * 被所有的对象所共享 * 可以直接使用类名来调用 * 静态所修饰的成员加载优先于对象,随着类的加载而加载 ...
- Erlang语言之简述及安装
1. 简述 Erlang在1991年由爱立信公司向用户推出了第一个版本,经过不断的改进完善和发展,在1996年爱立信又为所有的Erlang用户提供了一个非常实用且稳定的OTP软件库并在1998年发布了 ...
- .Net Core MVC 基于Cookie进行用户认证
在打代码之前先说一下思路. 登录的的时候服务端生成加密的字符串(用户名.id.当前时间)并且存入客户端cookie中,服务端的缓存中.对客户端的每次请求进行拦截,解密保存在cookie中的加密字符串. ...
- 013-结构体-C语言笔记
013-结构体-C语言笔记 学习目录 1.[掌握]返回指针的函数 2.[掌握]指向函数的指针 3.[掌握]结构体的声明 4.[掌握]结构体与数组 5.[掌握]结构体与指针 6.[掌握]结构体的嵌套 7 ...