日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ACdream 1431 Sum vs Product

發布時間:2025/3/15 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ACdream 1431 Sum vs Product 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題目鏈接: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的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。