对于一个数来说,它的除数是确定的,那么它的前驱也是确定的,而起点只能是1或2,所以只要类似筛法先预处理出每个数的除数个数

,然后递推出每个数往前的延伸的链长,更新最大长度,记录对应数字。找到maxn以后,根据最后一个数找到前驱,并记录到ans数组中。

代码来自队友

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iostream>
#include<set>
#include<map>
#define mod 1000000007
#define inf 1000000001
#define big 1570000
using namespace std; int d[big+];
int dp[big+];
int ans[big+]; void find()
{ for (int i = ; i <big; i++)
{
for (int j = i; j <= big; j += i)
d[j]++;
}
} int main()
{
find();
dp[] = ;
dp[] = ;
int maxn = ;
int re;
for (int i = ; i <=big; i++)
{
dp[i] = dp[i - d[i]] + ;
if (dp[i] > maxn)
{
maxn = dp[i];
re = i;
}
}
for (int i = maxn; i >= ; i--)
{
ans[i] = d[re];
re -= d[re];
}
int n;
scanf("%d", &n);
if (n > maxn)
printf("Impossible\n");
else
{
for (int i = ; i < n; i++)
{
printf("%d ", ans[i]);
}
printf("%d\n", ans[n]);
}
return ;
}

URAL 2047 Maths (数学)的更多相关文章

  1. URAL 2047 Maths 打表 递推

    MathsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action? ...

  2. [杂题]URAL2047. Maths

    题意:构造一个长度为n的串,使得 除了第一个以外,每个位置的前缀和的因子个数恰好等于该位置上的数. n$\le 100000$ 举个例子$a_i$:2   4    6     6    4    8 ...

  3. steam

    1.steam 教育 Science(科学), Technology(技术), Engineering(工程), Arts(艺术), Maths(数学) 2.  steam 平台 Steam英文原译为 ...

  4. VBA编程常用词汇英汉对照表

    表 20‑1到表 20‑8是VBA编程中使用频率最高的英文单词,按字母排序.词性列中,a表示形容词,n表示名词,v表示动词,p表示介词以及其他词性. 表 20‑1 VBA编程常用词汇表 单词 中文 词 ...

  5. URAL 1876 Centipede's Morning(数学)

    A centipede has 40 left feet and 40 right feet. It keeps a left slippers and b right slippers under ...

  6. URAL 1820. Ural Steaks(数学啊 )

    题目链接:space=1&num=1820" target="_blank">http://acm.timus.ru/problem.aspx? space ...

  7. (纪录片)数学的故事 The Story of Maths (2008)

    简介: 导演: Robin Dashwood编剧: Marcus du Sautoy主演: Marcus du Sautoy类型: 纪录片官方网站: www.bbc.co.uk/programmes/ ...

  8. ural 2029 Towers of Hanoi Strike Back (数学找规律)

    ural 2029 Towers of Hanoi Strike Back 链接:http://acm.timus.ru/problem.aspx?space=1&num=2029 题意:汉诺 ...

  9. ural 2032 Conspiracy Theory and Rebranding (数学水题)

    ural 2032  Conspiracy Theory and Rebranding 链接:http://acm.timus.ru/problem.aspx?space=1&num=2032 ...

随机推荐

  1. monkey之monkeyServer

    基本命令: adb shell monkey --port 1080 & adb forward tcp:1080 tcp:1080 telnet 127.0.0.1 1080 启动andro ...

  2. Flutter实战视频-移动电商-57.购物车_在Model中增加选中字段

    57.购物车_在Model中增加选中字段 先修改model类 model/cartInfo.dart类增加是否选中的属性 修改provide 修改UI部分pages/cart_page/cart_it ...

  3. Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例

    今天要讲的 用fiddler来监听,昨天的客户端的请求 这是一个post的请求 这是响应的数据 Expores_in超时时间, 今天的内容 在服务端再声明一个client端 wpf的应用的效果图 首先 ...

  4. python 三元表达式 列表推导式,生成器表达式。递归,匿名函数, 内置函数

    三元表达式 三元表达式仅应用于: 1.条件成立返回一个值 2.条件不成立返回一个值 res = x if x>y else y print(res) name= input("姓名&g ...

  5. CodeForces Gym 100685J Just Another Disney Problem (STL,排序)

    题意:给定你大小未知的n个数,你允许有不超过一万次的询问,每次询问两个数,第i个数是否比第j个数小?然后后台会返回给你一个结果YES或者NO(即一行输入), 然后经过多次询问后,你需要给出一个正确的原 ...

  6. flex(1)

    flex使用的actionscript语言遵守ECMA-262标准,这与javascript语言是一致的,由此可见二者语法的相似.

  7. FileWriter 写文件

    FileWriter fw = new FileWriter("C://Users//pc//Desktop//aaa.txt",true); fw.write("201 ...

  8. 洛谷 - P2424 - 约数和 - 整除分块

    https://www.luogu.org/problemnew/show/P2424 记 \(\sigma(n)\) 为n的所有约数之和,例如 \(\sigma(6)=1+2+3+6=12\) . ...

  9. 668. Kth Smallest Number in Multiplication Table

    Nearly every one have used the Multiplication Table. But could you find out the k-th smallest number ...

  10. IT兄弟连 JavaWeb教程 Servlet会话跟踪 经典案例

    案例需求:编写一个servlet,可以向session中存放一个消息,再编写一个servlet可以从session取得session中存放的这个消息. 案例实现: package com.xdl.se ...