1047A_Little C Loves 3 I(构造)
1 second
256 megabytes
standard input
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.
A single line containing one integer nn (3≤n≤1093≤n≤109) — the integer Little C has.
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.
3
1 1 1
233
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.注意这个构造是任意的,只要满足条件即可
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
int n;
while(~scanf("%d",&n))
{
if(n%==)
printf("1 1 %d\n",n-);
else
printf("1 2 %d\n",n-);
}
return ;
}
1047A_Little C Loves 3 I(构造)的更多相关文章
- C 洛谷 P3599 Koishi Loves Construction [构造 打表观察]
题目描述 Koishi决定走出幻想乡成为数学大师! Flandre听说她数学学的很好,就给Koishi出了这样一道构造题: Task1:试判断能否构造并构造一个长度为的的排列,满足其个前缀和在模的意义 ...
- hdu 5646DZY Loves Partition(构造)
DZY Loves Partition Accepts: 154 Submissions: 843 Time Limit: 4000/2000 MS (Java/Others) Memory ...
- 洛谷P3599 Koishi Loves Construction 构造
正解:构造 解题报告: 传送门! 这题俩问嘛,就分成两个问题港QwQ 就按顺序趴,先港第一问QwQ 首先要发现,n在膜n意义下就是0嘛 那作为前缀和的话显然它就只能放在第一个 然后再想下,发现,如果n ...
- P3599 Koishi Loves Construction——构造题
题目 Task1:试判断能否构造并构造一个长度 $n$ 的 $1...n$ 的排列,满足其 $n$ 个前缀和在模 $n$ 的意义下互不相同 Task2:试判断能否构造并构造一个长度 $n$ 的 $1. ...
- BZOJ3569: DZY Loves Chinese II(线性基构造)
Description 神校XJ之学霸兮,Dzy皇考曰JC. 摄提贞于孟陬兮,惟庚寅Dzy以降. 纷Dzy既有此内美兮,又重之以修能. 遂降临于OI界,欲以神力而凌♂辱众生. 今Dzy有一魞歄图, ...
- hdu 5675 ztr loves math(数学技巧)
Problem Description ztr loves research Math.One day,He thought about the "Lower Edition" o ...
- [HDU5677]ztr loves substring
ztr loves substring Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Othe ...
- 【BZOJ3563/3569】DZY Loves Chinese II 线性基神题
[BZOJ3563/3569]DZY Loves Chinese II Description 神校XJ之学霸兮,Dzy皇考曰JC. 摄提贞于孟陬兮,惟庚寅Dzy以降. 纷Dzy既有此内美兮,又重之以 ...
- 【题解】P3599 Koishi Loves Construction
[题解]P3599 Koishi Loves Construction \(\mod n\) 考虑如何构造,发现\(n\)一定在第一位,不然不行.\(n\)一定是偶数或者是\(1\),不然 \(n|\ ...
随机推荐
- PowerDesigner最基础的使用方法入门学习(一)
1:入门级使用PowerDesigner软件创建数据库(直接上图怎么创建,其他的概念知识可自行学习) 我的PowerDesigner版本是16.5的,如若版本不一样,请自行参考学习即可.(打开软件即是 ...
- 1120 Friend Numbers (20 分)
1120 Friend Numbers (20 分) Two integers are called "friend numbers" if they share the same ...
- sqlserver 查询重复数据
use StudentManageDB go ,,) ,,) ,,) select * from ScoreList order by StudentId --在知道那个字段重复的情况 --查询所有重 ...
- 安装npm报错 npm cache clean --force 搞定
- join、on、where、having的使用区别
on.where.having的区别 on.where.having这三个都可以加条件的子句中,on是最先执行,where次之,having最后.on是在生成中间的临时表时起作用的,where,hav ...
- CRM 2016 IFrame_A嵌入 EXT.net 页面 a.aspx,刷新另一IFrame_B嵌入 b.aspx gird.
说白了就是一个IFrame页面,执行另一IFrame页面的函数. a.aspx JS: parent.Xrm.Page.getControl("IFRAME_B").getObj ...
- BCGcontrolBar(七) 添加仪表盘、动态图表显示等控件
BCG的 BCGPGaugesDemo有众多仪表盘控件可以参考使用 编写时同ListCtrl一样 在停靠面板上加入仪表盘和动态曲线 主要代码 //插入CPU图形 pContainer->SetF ...
- ElasticSearch概述
ElasticSearch 产生背景 Lucene 定义 ElasticSearch 定义 ElasticSearch vs Lucene ElasticSearch vs Solr Elastic ...
- Struts2学习:Action获取properties文件的值
配置文件路径: 配置内容: 方法一: Action内被调用的函数添加下段代码: Properties props = new Properties(); props.load(UploadFileAc ...
- 03-spark kafka
1.概念 Kafka是一个开源的消息系统.由Scala编写,它具备以下特点: ①消息持久化: 为了从大数据中获取有价值的信息,任何信息的丢失都是负担不起的.使用Kafka时,message会被存储并且 ...