Continuous Login


Time Limit: 2 Seconds      Memory Limit: 131072 KB      Special Judge


Pierre is recently obsessed with an online game. To encourage users to log in, this game will give users a continuous login reward. The mechanism of continuous login reward is as follows:
If you have not logged in on a certain day, the reward of that day is 0, otherwise the reward is the previous day's plus 1.

On the other hand, Pierre is very fond of the number N. He wants to get exactly N points reward with the least possible interruption of continuous login.

Input

There are multiple test cases. The first line of input is an integer T indicates the number of test cases. For each test case:

There is one integer N (1 <= N <= 123456789).

Output

For each test case, output the days of continuous login, separated by a space.

This problem is special judged so any correct answer will be accepted.

Sample Input

4
20
19
6
9

Sample Output

4 4
3 4 2
3
2 3

Hint

20 = (1 + 2 + 3 + 4) + (1 + 2 + 3 + 4)

19 = (1 + 2 + 3) + (1 + 2 + 3 + 4) + (1 + 2)

6 = (1 + 2 + 3)

9 = (1 + 2) + (1 + 2 + 3)

Some problem has a simple, fast and correct solution.


题目的意思是给出一个数n是的n分成若干的数的和,每个数是重1累加奥x的,保证数字个数最少

找规律发现最多出现3项,分别对1项2项3项讨论,枚举加二分

#include <iostream>
#include<queue>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include <cstring>
using namespace std;
#define LL long long
int a[100005]; int main()
{
int T,n;
a[0]=0;
for(int i=1;i<100005;i++)
a[i]=a[i-1]+i;
scanf("%d",&T);
while(T--)
{
int flag=0;
scanf("%d",&n);
for(int i=0;i<100000;i++)
{
if(a[i]==n){
flag=1;
printf("%d\n",i);
break;
}
if(a[i]>n) break;
} if(flag) continue;
for(int i=0;a[i]<n;i++)
{
int x=n-a[i];
int pos=lower_bound(a,a+100000,x)-a;
if(a[pos]==x)
{
flag=1;
printf("%d %d\n",i,pos);
break;
}
}
if(flag) continue;
for(int i=0;a[i]<n;i++)
{
for(int j=0;a[j]<n-a[i];j++)
{
int x=n-a[i]-a[j];
int pos=lower_bound(a,a+100000,x)-a;
if(a[pos]==x)
{
flag=1;
printf("%d %d %d\n",i,j,pos);
break;
}
}
if(flag) break;
} } return 0;
}

ZOJ3768 Continuous Login 2017-04-14 12:47 45人阅读 评论(0) 收藏的更多相关文章

  1. hdu 1030 Delta-wave (C++, 0ms, explanatory comments.) 分类: hdoj 2015-06-15 12:21 45人阅读 评论(0) 收藏

    problem description http://acm.hdu.edu.cn/showproblem.php?pid=1030 #include <cstdio> #include ...

  2. Hdu2181 哈密顿绕行世界问题 2017-01-18 14:46 45人阅读 评论(0) 收藏

    哈密顿绕行世界问题 Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Sub ...

  3. ios UIKit动力 分类: ios技术 2015-07-14 12:55 196人阅读 评论(0) 收藏

    UIkit动力学是UIkit框架中模拟真实世界的一些特性. UIDynamicAnimator 主要有UIDynamicAnimator类,通过这个类中的不同行为来实现一些动态特性. 它一般有两种初始 ...

  4. ZOJ3770Ranking System 2017-04-14 12:42 52人阅读 评论(0) 收藏

    Ranking System Time Limit: 2 Seconds      Memory Limit: 65536 KB Few weeks ago, a famous software co ...

  5. Log4j 2使用教程 分类: B1_JAVA 2014-07-01 12:26 314人阅读 评论(0) 收藏

    转载自 Blog of 天外的星星: http://www.cnblogs.com/leo-lsw/p/log4j2tutorial.html Log4j 2的好处就不和大家说了,如果你搜了2,说明你 ...

  6. .net 实现Office文件预览 Word PPT Excel 2015-01-23 08:47 63人阅读 评论(0) 收藏

    先打个广告: .Net交流群:252713569 本人QQ :524808775 欢迎技术探讨, 近期公司要求上传的PPT和Word都需要可以在线预览.. 小弟我是从来没有接触过这一块的东西 感觉很棘 ...

  7. Speed Limit 分类: POJ 2015-06-09 17:47 9人阅读 评论(0) 收藏

    Speed Limit Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 17967   Accepted: 12596 Des ...

  8. 单链表操作B 分类: 链表 2015-06-07 12:42 15人阅读 评论(0) 收藏

    数据结构上机测试2-2:单链表操作B TimeLimit: 1000ms Memory limit: 65536K 题目描述 按照数据输入的相反顺序(逆位序)建立一个单链表,并将单链表中重复的元素删除 ...

  9. hdu 1035 (usage of sentinel, proper utilization of switch and goto to make code neat) 分类: hdoj 2015-06-16 12:33 28人阅读 评论(0) 收藏

    as Scott Meyers said in his book Effective STL, "My advice on choosing among the sorting algori ...

随机推荐

  1. C# 通过二进制,将多个文件合并为一个。

    C# 通过二进制,将多个文件合并为一个. /// <summary> /// 合并文件 /// </summary> /// <param name="strD ...

  2. Data_Structure03-栈和队列

    一.学习总结 1.写出你认为本周学习中比较重要的知识点关键词 ·抽象数据类型 ·栈和队列 2.思维导图 二.PTA实验作业 选题: 1.7-1 jmu-字符串是否对称(20 分) 2.7-4(选做) ...

  3. Java-Runoob-高级教程-实例-字符串:04. Java 实例 - 字符串替换

    ylbtech-Java-Runoob-高级教程-实例-字符串:04. Java 实例 - 字符串替换 1.返回顶部 1. Java 实例 - 字符串替换  Java 实例 如何使用java替换字符串 ...

  4. Bootstrap-Plugin:警告框(Alert)插件

    ylbtech-Bootstrap-Plugin:警告框(Alert)插件 1.返回顶部 1. Bootstrap 警告框(Alert)插件 警告框(Alert)消息大多是用来向终端用户显示诸如警告或 ...

  5. Windows常用内容渗透命令

    假设现在已经拥有一台内网[域]机器,取名X-007. 1-1.内网[域]信息收集 A.本机X-007信息收集. [+]------用户列表[Windows用户列表/邮件用户/...] ----> ...

  6. C++ - 容器概述

    一 迭代器iterator 5种类别 常用的迭代器 常用的迭代器 二 分配算符Allocators 三 容器简介 STL标准容器类简介 标准容器类 说明 顺序性容器 关联容器 容器适配器 所有标准库共 ...

  7. 【CentOS 6.5】 Qt Creator 启动失败

    在CentOS 6.5中 点击 [应用程序]->[编程]->Qt Creator , 没有反应,Creator没有启动,转而进入Shell cd /opt/Qt5.2.1/Tools/Qt ...

  8. Selenium Webdriver——AutoIt和robot实现右键另存

    方案如下: 1.selenium 弹出右键菜单 2.robot选择相关菜单 3.调用autoIt实现windows gui另存操作 test case 如下: 1.打开百度(谷歌浏览器) 2.选择百度 ...

  9. 横向文本框 cursor:pointer 出现手型

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  10. SC命令安装window服务

    sc create Styler binpath= "D:\Styler\Styler.exe" start= auto displayname= "Styler&quo ...