1222. Chernobyl’ Eagles

Time limit: 1.0 second
Memory limit: 64 MB

A Chernobyl’ eagle has several heads (for example, the eagle on the Russian National Emblem is a very typical one, having two heads; there exist Chernobyl’ eagles having twenty-six, one and even zero heads). As all eagles, Chernobyl’ eagles are very intelligent. Moreover, IQ of a Chernobyl’ eagle is exactly equal to the number of its heads. These eagles can also enormously enlarge their IQ, when they form a group for a brainstorm. IQ of a group of Chernobyl’ eagles equals to the product of IQ’s of eagles in the group. So for example, the IQ of a group, consisting of two 4-headed eagles and one 7-headed is 4*4*7=112. The question is, how large can be an IQ of a group of eagles with a given total amount of heads.

Input

There is one positive integer N in the input, N ≤ 3000 — the total number of heads of Chernobyl’ eagles in a group.

Output

Your program should output a single number — a maximal IQ, which could have a group of Chernobyl’ eagles, with the total amount of heads equal to N.

Sample

input output
5
6
Problem Author: folklore, proposed by Leonid Volkov
Problem Source: The Seventh Ural State University collegiate programming contest
Difficulty: 141
 
题意:和为n,拆成若干个数,使得乘积最大
分析:显然,先拆成尽量多的3,在拆成2,这样乘积最大,因为肯定不能拆成1,然后之后所有数都可以用2,3构成,根据归纳法可以证明。
注意,4要拆成两个2
 #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
using namespace std;
typedef long long LL;
typedef double DB;
#define For(i, s, t) for(int i = (s); i <= (t); i++)
#define Ford(i, s, t) for(int i = (s); i >= (t); i--)
#define Rep(i, t) for(int i = (0); i < (t); i++)
#define Repn(i, t) for(int i = ((t)-1); i >= (0); i--)
#define rep(i, x, t) for(int i = (x); i < (t); i++)
#define MIT (2147483647)
#define INF (1000000001)
#define MLL (1000000000000000001LL)
#define sz(x) ((int) (x).size())
#define clr(x, y) memset(x, y, sizeof(x))
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define ft first
#define sd second
#define mk make_pair
inline void SetIO(string Name) {
string Input = Name+".in",
Output = Name+".out";
freopen(Input.c_str(), "r", stdin),
freopen(Output.c_str(), "w", stdout);
} inline int Getint() {
int Ret = ;
char Ch = ' ';
while(!(Ch >= '' && Ch <= '')) Ch = getchar();
while(Ch >= '' && Ch <= '') {
Ret = Ret*+Ch-'';
Ch = getchar();
}
return Ret;
} const int N = , Mod = ;
int Arr[N], Len;
int n; inline void Input() {
scanf("%d", &n);
} inline void Mul(int x) {
For(i, , Len) Arr[i] *= x;
For(i, , Len) {
Arr[i+] += Arr[i]/Mod;
Arr[i] %= Mod;
}
while(Arr[Len+]) {
Len++;
Arr[Len+] += Arr[Len]/Mod;
Arr[Len] %= Mod;
}
} inline void Solve() {
Arr[] = , Len = ;
while(n > ) Mul(), n -= ;
if(n == ) Mul(), n -= ;
if(n == ) Mul(), n -= ;
if(n == ) Mul(), n -= ; printf("%d", Arr[Len]);
Ford(i, Len-, ) printf("%04d", Arr[i]);
puts("");
} int main() {
#ifndef ONLINE_JUDGE
SetIO("F");
#endif
Input();
Solve();
return ;
}

ural 1222. Chernobyl’ Eagles的更多相关文章

  1. 记忆化搜索(DFS+DP) URAL 1223 Chernobyl’ Eagle on a Roof

    题目传送门 /* 记忆化搜索(DFS+DP):dp[x][y] 表示x个蛋,在y楼扔后所需要的实验次数 ans = min (ans, max (dp[x][y-i], dp[x-1][i-1]) + ...

  2. URAL 1223. Chernobyl’ Eagle on a Roof

    题目链接 以前做过的一题,URAL数据强点,优化了一下. #include <iostream> #include <cstdio> #include <cstring& ...

  3. URAL DP第一发

    列表: URAL 1225 Flags URAL 1009 K-based Numbers URAL 1119 Metro URAL 1146 Maximum Sum URAL 1203 Scient ...

  4. SQL SERVER错误:已超过了锁请求超时时段。 (Microsoft SQL Server,错误: 1222)

    在SSMS(Microsoft SQL Server Management Studio)里面,查看数据库对应的表的时候,会遇到"Lock Request time out period e ...

  5. 后缀数组 POJ 3974 Palindrome && URAL 1297 Palindrome

    题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串 ...

  6. ural 2071. Juice Cocktails

    2071. Juice Cocktails Time limit: 1.0 secondMemory limit: 64 MB Once n Denchiks come to the bar and ...

  7. ural 2073. Log Files

    2073. Log Files Time limit: 1.0 secondMemory limit: 64 MB Nikolay has decided to become the best pro ...

  8. ural 2070. Interesting Numbers

    2070. Interesting Numbers Time limit: 2.0 secondMemory limit: 64 MB Nikolay and Asya investigate int ...

  9. ural 2069. Hard Rock

    2069. Hard Rock Time limit: 1.0 secondMemory limit: 64 MB Ilya is a frontman of the most famous rock ...

随机推荐

  1. axis2 webservice 发布、调用与项目集成

    发布 1.在apache官网下载axis2包,下载Binary Distribution和War Distribution两个zip. 2.将war放入tomcat webapps下部署.并输入 ht ...

  2. FZU2127:养鸡场

    Problem Description Jason买来了n米长的竹篱笆,打算将n米长的竹篱笆所实用来围成一个三角形的养鸡场.为方便起见.养鸡场三条边的长度都为正整数. 同一时候.他想让自己的养鸡场看起 ...

  3. 粒子滤波particle filter和目标跟踪

    粒子滤波用于跟踪,参考:http://www.cnblogs.com/tornadomeet/archive/2012/03/18/2404817.html http://blog.csdn.net/ ...

  4. 秀尔算法:破解RSA加密的“不灭神话”

    RSA加密 VS 秀尔算法 作为RSA加密技术的终结者——“太多运算,无法读取”的秀尔算法(Shor’s algorithm)不是通过暴力破解的方式找到最终密码的,而是利用量子计算的并行性,可以快速分 ...

  5. SpringMVC配置easyui-datagrid

    SprimgMVC的UserController.java @RequestMapping(value = "listUserForJson") @ResponseBody pub ...

  6. 【JavaScript】ReactJS&NodeJS了解资料

    ReactJS: GitHub:https://github.com/facebook/react React 入门实例教程:http://www.ruanyifeng.com/blog/2015/0 ...

  7. Unique Paths | & ||

    Unique Paths I A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diag ...

  8. codeforces 374A Inna and Pink Pony 解题报告

    题目链接:http://codeforces.com/problemset/problem/374/A 题目意思:给出一个 n 行  m 列 的棋盘,要将放置在坐标点为(i, j)的 candy 移动 ...

  9. OC内存管理--zombie对象

    当我们对于内存进行手动管理的时候,会出现两种错误:一种是野指针错误,一种则为内存泄露.这两点也是我们去管理内存时最终要解决的问题. 内存泄漏是指:不在使用的对象,一直保留在内存中未被销毁,一直占有着内 ...

  10. ios学习总结(1) -- 创建第一个ios项目

    原文地址 下载并打开xcode. 接着新建一个工程,如下图所示: 点击Create a new Xcode project,之后选择ios下的Application,点击Single View App ...