题目链接:http://115.28.76.232/problem?

pid=1431

Sum vs Product

Time Limit: 4000/2000MS (Java/Others)Memory Limit: 128000/64000KB (Java/Others)
SubmitStatisticNext Problem

Problem Description

Peter has just learned mathematics. He learned how to add, and how to multiply. The fact that 2 + 2 = 2 × 2 has amazed him greatly. Now he wants find more such examples. Peters calls a collection of numbers beautiful if the product of the numbers in it is equal to their sum.

For example, the collections {2, 2}, {5}, {1, 2, 3} are beautiful, but {2, 3} is not.

Given n, Peter wants to find the number of beautiful collections with n numbers. Help him!

Input

The first line of the input file contains n (2 ≤ n ≤ 500)

Output

Output one number — the number of the beautiful collections with n numbers.

Sample Input

2
5

Sample Output

1
3

Hint

The collections in the last example are: {1, 1, 1, 2, 5}, {1, 1, 1, 3, 3} and {1, 1, 2, 2, 2}.

Source

Andrew Stankevich Contest 23

Manager

mathlover
SubmitStatistic

这个题目事实上仅仅要枚举下因子。暴力dfs一下就能过。。

//#pragma comment(linker, "/STACK:36777216")
#include <functional>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <climits>
#include <cassert>
#include <complex>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;
#define CLR(A,B) memset(A,B,sizeof(A))
#define CPY(A,B) memcpy(A,B,sizeof(B))
#define long long ll
#define MP(A,B) make_pair(A,B)
int N;
long long cnt;
int dfs(int now,long long sum,long long mul,int pre){if(now==N){cnt++;return 1;}for(int i=pre;i<2000;i++){int ts=sum+i,tm=mul*i;int ms=ts+N-now-1,mm=tm;if(ms==mm){cnt++;continue;}if(ms<mm) return 0;dfs(now+1,ts,tm,i);}
}
int main(){int F[550];for(int i=2;i<=500;i++){N=i;cnt=0;dfs(0,0,1,2);F[i]=cnt;}while(~scanf("%d",&N)) printf("%d\n",F[N]);return 0;
}

转载于:https://www.cnblogs.com/llguanli/p/7047322.html

ACdream 1431 Sum vs Product相关推荐

  1. 【概率证明】—— sum and product rules of probability

    1. sum and product rules of probability ⎧⎩⎨p(x)=∫p(x,y)dyp(x,y)=p(x|y)p(y) \left\{ \begin{split} &am ...

  2. LeetCode Subarray Sum Equals K

    原题链接在这里:https://leetcode.com/problems/subarray-sum-equals-k/description/ 题目: Given an array of integ ...

  3. MySQL中sum和count用法总结

    MySQL中sum和count用法总结 1.sum 2.count 例子:要求:查询出2门及2门以上不及格者的平均成绩. 3.MySQL 分组之后如何统计记录条数 gourp by 之后的 count ...

  4. 使用nGraph的Intel®Xeon®上的高性能TensorFlow

    使用nGraph的Intel®Xeon®上的高性能TensorFlow High-performance TensorFlow* on Intel® Xeon® Using nGraph 最近宣布了n ...

  5. 【C++】C++11 STL算法(七):排列操作(Permutation operations)、数值操作(Numeric operations)

    排列操作(Permutation operations) 一.is_permutation 1.原型: template< class ForwardIt1, class ForwardIt2 ...

  6. C++向量类模板(支持实数向量与复数向量的各种运算)

    2019独角兽企业重金招聘Python工程师标准>>> 头文件: /** Copyright (c) 2008-2011 Zhang Ming (M. Zhang), zmjerry ...

  7. VBA编程常用语句(转载)

    1.Option Explicit '强制对模块内所有变量进行声明 Option Private Module '标记模块为私有,仅对同一工程中其它模块有用,在宏对话框中不显示 Option Comp ...

  8. 神经网络php代码,慢慢研究

    为什么80%的码农都做不了架构师?>>>    <?php require_once("class_neuralnetwork.php"); functio ...

  9. 代币转账_手把手教你从源代码开始搭建多节点以太坊私链(五)部署智能合约及代币发行...

    一.安装以太坊合约编译环境 安装solc 智能合约代码的编译可以通过第三方平台或者软件.不过,为了安全起见,还是搭建自己的编译器比较好.(But be aware that if the compil ...

最新文章

  1. vs2015 企业版、专业版如何破解(秘钥)
  2. php下关于Cannot use a scalar value as an array的解决办法
  3. linux 下的Memcached安装和配置
  4. TABLES ABOUT CRM MARTETING
  5. Node Capital生态布局初成,部分项目差强人意
  6. view渐变色,透明度渐变
  7. 【REACT NATIVE 系列教程之十三】利用LISTVIEW与TEXTINPUT制作聊天/对话框获取组件实例常用的两种方式...
  8. 4 weekend110的hive入门
  9. 计算机类实训室建设公司,计算机专业实训室建设方案修改
  10. 一个大数据屌丝的一天
  11. QQ红包金额分配算法
  12. 一行脚本批量下载哔哩哔哩视频
  13. 全国高中生计算机联赛,全国中学生五大学科竞赛
  14. 计算机与管理科学的交叉与融合,计算机信息管理专业与其他专业的交叉融合论文...
  15. char* p 和 char p[]区别及应用
  16. 《绝地求生:大逃杀》百万级别数据分析项目,还有源码+数据
  17. JSP+MySQL校园新闻网站(5)–新闻查看功能开发
  18. win7 常用快捷键
  19. 使用Java导出数据到Excel
  20. 区域生长算法(附MATLAB代码实现)

热门文章

  1. 逆向基础之C语言 第一篇
  2. python基础——迭代器与生成器
  3. Java Instant类
  4. Bootloader加载过程分析
  5. hdu1754(简单线段树)
  6. zcmu-1957(状态压缩枚举)
  7. 如何构建一个分布式爬虫:理论篇
  8. java自定义字段_java-使用自定义字段构造函数将HTML属性添加...
  9. centos7查看当前系统时间、_CentOS7.4.1708查看系统相关信息及系统的初步优化
  10. 三因素三水平正交表l9_影响多腔导管挤出机头设计的关键因素