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只黑鼠 龙和王妃轮流从袋子里抓老鼠.谁先抓到白色老鼠谁就赢. 王妃每次 ...
随机推荐
- Linux基础篇,Shell
一.基本知识 Shell Script是一种脚本.可以用来极大的简化计算机的管理.在谱写shell script的时候,需要注意以下问题: 1. 指令的执行是从上而下. 从左而右的分析与执行: 2. ...
- ConcurrentHashMap中节点数目并发统计的实现原理
前言: 前段时间又看了一遍ConcurrentHashMap的源码,对该并发容器的底层实现原理有了更进一步的了解,本想写一篇关于ConcurrentHashMap的put方法所涉及的初始化以及扩容操作 ...
- NumPy学习1:基本概念
NumPy的数组类被称作 ndarray .通常被称作数组.注意numpy.array和标准Python库类array.array并不相同,后者只处理一维数组和提供少量功能.更多重要ndarray对象 ...
- shell-function 删除目录和文件
function sDelDirFile() { if [ "$#" -eq 1 ];then if [ -e "$1" ];then rm "$1& ...
- 表字段或表名出现Mysql关键字或保留字导致问题 Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have
MySQL 5.7使用的关键字和保留字 https://dev.mysql.com/doc/refman/5.7/en/keywords.html 当我们建表的时候如果使用了关键字或者保留字,则在执行 ...
- delphi使用ADO在sql数据库存取图片的方法
我一直不认为能把代码写的和天书一样的程序员是好的程序员,那不过是因为我真的对delphi也就是略懂皮毛,太深了看不懂.网上查询数据库存取图片的方式,看的是一头雾水,有人提出保存路径使用时再调用,方法很 ...
- Atcoder E - Crested Ibis vs Monster、
一看到题目就觉得是一个背包问题,但是不知道怎么写. 题解:直接求背包容量为2*h时所需要的花费.然后h~2h都是满足条件的,去最小值即可. code: #include<bits/stdc++. ...
- E - Farthest Nodes in a Tree
Given a tree (a connected graph with no cycles), you have to find the farthest nodes in the tree. Th ...
- 2. node xlsx的使用
1. 使用xlsx模块 const xlsx = require('xlsx'); //excel async exportexcel() { let arrayData = [ ['姓名', '电话 ...
- 统计字符串中每种字符出现的评率(HashMap中getOrDefault(K, V)方法的使用)
为了统计字符串中每种字符出现的频率,使用HashMap这种数据结构.其中,字符作为Key,出现的频率作为Value. 基本算法为: 1. 将字符串分成字符数组 2. (1)如果HashMap中的Key ...