对于一个数来说,它的除数是确定的,那么它的前驱也是确定的,而起点只能是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. HDOJ-1251

    统计难题 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131070/65535 K (Java/Others)Total Submi ...

  2. zz 堆空间与栈空间

    http://blog.sina.com.cn/s/blog_7321be1101013aua.htmlhttp://soft.chinabyte.com/os/51/12324551.shtmlht ...

  3. Python使用Timer实现验证码功能

    from threading import Timer import random class Code: def __init__(self): self.make_cache() def make ...

  4. monkeyRunner

    MonkeyRunner工具是使用Jython(使用Java编程语言实现的Python)写出来的,它提供了多个API,通过monkeyrunner API 可以写一个Python的程序来模拟操作控制A ...

  5. Lua教程 loadfile与loadstring

    在程序运行中有时需要运行用户输入的代码1.loadfile把文件编译为可执行的函数f=loadfile('\\temp\\a.lua')     ----给f方法赋值print(type(f))  - ...

  6. Winform禁止程序多开 &&禁止多开且第二次激活第一次窗口

    一.禁止多开问题,运用Mutex锁 在Program.cs中运用Mutex锁 bool createNew;using (System.Threading.Mutex mutex = new Syst ...

  7. HTML学习笔记(四)常用标签

    1.超链接 <a href="url">Link text</a> eg:<a href="http://www.w3school.com. ...

  8. django使用QQ企业邮箱发送邮件

    一.首先申请QQ企业邮箱 免费QQ企业邮箱地址如下:https://exmail.qq.com/signupfree?refer=intro#signup/free 二.配置自己的域名 在域名解析中添 ...

  9. POJ2406【KMP-next数组】

    关于next的解释原文:点点点 //#include <bits/stdc++.h> #include<cstdio> #include<string.h> #in ...

  10. 51nod 1021【区间DP】

    思路: dp[ i ] [ j ]代表取[ i ,j ]区间石子的最小值,然后dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+sum[j]-sum[i-1]); # ...