遇到这种都是数学题的,非常合理的爆了一个零。然后A题的原因是没有想到用map计数,还有数组开小了。。。

Problem A On Number of Decompositions into Multipliers

题意:给一个n个元素的数组ai求所有元素的乘积分解为n个数的情况总数。

思路:一次拆分数组元素,由于又大素数存在所以bixuyongmap标记然后推出公式这个直接看程序吧,不好打。

代码如下:

 1 /**************************************************
 2  * Author     : xiaohao Z
 3  * Blog     : http://www.cnblogs.com/shu-xiaohao/
 4  * Last modified : 2014-02-26 23:26
 5  * Filename     :
 6  * Description     :
 7  * ************************************************/
 8
 9 #include <iostream>
10 #include <cstdio>
11 #include <cstring>
12 #include <cstdlib>
13 #include <cmath>
14 #include <algorithm>
15 #include <queue>
16 #include <stack>
17 #include <vector>
18 #include <set>
19 #include <map>
20 #define MP(a, b) make_pair(a, b)
21 #define PB(a) push_back(a)
22
23 using namespace std;
24 typedef long long ll;
25 typedef pair<int, int> pii;
26 typedef pair<unsigned int,unsigned int> puu;
27 typedef pair<int, double> pid;
28 typedef pair<ll, int> pli;
29 typedef pair<int, ll> pil;
30
31 const int INF = 0x3f3f3f3f;
32 const double eps = 1E-6;
33 const int MOD = 1000000007;
34 ll C[20010][510];
35 map<ll, ll> mp;
36
37 const int MAXN=1000000;
38 int prime[MAXN+1];
39 void getPrime()
40 {
41     memset(prime,0,sizeof(prime));
42     for(int i=2; i<=MAXN; i++)
43     {
44         if(!prime[i])prime[++prime[0]]=i;
45         for(int j=1; j<=prime[0]&&prime[j]<=MAXN/i; j++)
46         {
47             prime[prime[j]*i]=1;
48             if(i%prime[j]==0) break;
49         }
50     }
51 }
52
53 void make(int n){
54     int temp = sqrt(n);
55     for(int i=1; prime[i] <= temp; i++){
56         while(n%prime[i]==0){
57             mp[prime[i]]++;
58             n/=prime[i];
59         }
60     }
61     if(n>1) mp[n] ++;
62 }
63
64 void init(){
65     memset(C, 0, sizeof C);
66     C[0][0] = 1;
67     for(int i=0; i<20010; i++){
68         C[i][0] = 1;
69         if(i < 510)C[i][i] = 1;
70         for(int j=1; j<min(510, i); j++){
71             C[i][j] = (C[i-1][j] + C[i-1][j-1]) % MOD;
72         }
73     }
74 }
75
76 int main()
77 {
78 //    freopen("in.txt", "r", stdin);
79
80     int n, tnum;
81     while(scanf("%d", &n)!=EOF){
82         init();getPrime();mp.clear();
83         for(int i=0; i<n; i++){
84             scanf("%d", &tnum);
85             make(tnum);
86         }
87         ll ans = 1, tans;
88         for(map<ll, ll>::iterator it=mp.begin(); it!=mp.end();++it){
89             tans = 0;
90             for(int j=0; j<n; j++) {
91                 tans = (tans+(C[n][j+1]*C[it->second-1][j])%MOD)%MOD;
92             }
93             ans = ans * tans;
94             ans%=MOD;
95         }
96         printf("%I64d\n", ans);
97     }
98     return 0;
99 }

View Code

转载于:https://www.cnblogs.com/shu-xiaohao/p/3570570.html

Codeforces Round #232 (Div. 1) 解题报告相关推荐

  1. CodeCraft-19 and Codeforces Round #537 (Div. 2)解题报告

    Codeforces Round #537 (Div. 2) 题解报告 A. Superhero Transformation 题意 问能否通过把辅音字母换成另一个辅音字母,元音字母换成另一个元音字母 ...

  2. Codeforces Round #702 (Div. 3)解题报告

    Codeforces Round #702 (Div. 3) 全部题解 读错题意,写了半天真是心态爆炸,总的来看这次题目不难的. A. Dense Array http://codeforces.co ...

  3. Codeforces Round #264 (Div. 2) 解题报告

    Source:  http://codeforces.com/contest/463 打得比较差..第三题想写nlgn的,结果调了很久又wa,以为写挫,过了很久发现做法有问题..最后两题惨淡收场.第四 ...

  4. Codeforces Round #219 (Div. 2) 解题报告

    Problem A Collecting Beats is Fun 题意:就是音乐游戏在4*4的网上一些格子需要在固定的时间点,告诉你一只手同一时间能点几个.问你能不能通关(就是一个不丢) 思路:水题 ...

  5. Codeforces Round #535 (Div. 3) 解题报告

    CF1108A. Two distinct points 做法:模拟 如果两者左端点重合就第二条的左端点++就好,然后输出左端点 #include <bits/stdc++.h> usin ...

  6. Codeforces Round #578 (Div. 2) 题解报告

    A. Hotelier sb模拟,直接按题意模拟就可以了. B. Block Adventure Gildong is playing a video game called Block Advent ...

  7. BestCoder Round #77 (div.2)解题报告

    昨晚和Yveh合作的成果-- T1 传送门 题意:给一个正整数集合,求集合中各个子集里各元素的总异或 思路:对于一个数x对自己异或的结果,异或偶数次是x,奇数次为0,而且一个集合的非空子集数目为2n− ...

  8. Codeforces Round #700 (Div. 2)A~D2解题报告

    Codeforces Round #700 (Div. 2)A~D2解题报告 A Yet Another String Game 原题链接 http://codeforces.com/contest/ ...

  9. Codeforces Round #693 (Div. 3)A~G解题报告

    Codeforces Round #693 (Div. 3)A~G解题报告 A Cards for Friends 原题信息 http://codeforces.com/contest/1472/pr ...

  10. Codeforces Round #697 (Div. 3)A~G解题报告

    Codeforces Round #697 (Div. 3)A~G解题报告 题 A Odd Divisor 题目介绍 解题思路 乍一想本题,感觉有点迷迷糊糊,但是证难则反,直接考虑没有奇数因子的情况, ...

最新文章

  1. 某央企程序员炫耀:央企研发岗才是性价比天花板!955,不卷不裁,6险2金,500元单身公寓!...
  2. 作为一个新人,怎样学习嵌入式Linux?
  3. 使用BCH彩色币方案发行Token已实现
  4. 笔试算法题--汪仔换道具
  5. 计算机主机清理步骤,怎么清理主机灰尘 清理灰尘教程
  6. android 如何添加第3方lib库到kernel中
  7. 音视频中时间戳增量计算
  8. UVa 11388 - GCD LCM
  9. 睡前一分钟打造完美下半身 - 健康程序员,至尚生活!
  10. lamber表达式sql_lambda表达式转换sql
  11. matlab求最短路径代码_【高等数学】复数,通往真理的最短路径
  12. sprintf()、fprintf()的使用方法
  13. Multi-thread--C++11中std::condition_variable的使用
  14. 一张图学会python高清图-一张图让你学会Python
  15. sniffer经典指南 一
  16. 20200827 plecs blockset更新版本
  17. MapReduce计算PMI
  18. 【Cloudaily】3.15五招教你辨别真假云计算,2017 Gartner数据科学魔力象限出炉
  19. python爬虫岗位招聘_Python爬虫系列2-抓取拉钩网2020年最新互联网岗位招聘信息
  20. maven打开edge的闪退

热门文章

  1. 此男因为什么被送进医院?
  2. 玩转docker、Swarm、Kubernetes
  3. 物理内存管理之zone详解
  4. (三)洞悉linux下的Netfilteriptables:内核中的rule,match和target
  5. 嵌入式Linux/Android疑难杂症工作笔记
  6. 自己编译操作系统,安装systemtap
  7. 最短路大大大跟着合集
  8. golang 使用openoffice 生成pdf_使用golang生成PDF文件
  9. android studio 顶部导航栏_移动端控件(五)-标签导航(Tabs)和分段控件(Segmented Controls)...
  10. missing arguments for method toArray in trait Collection