题目地址: http://acm.fzu.edu.cn/problem.php?pid=1607

给定一个n,将n平均分成m份,问有几种方法,每种方法中找出最大的数。思路:就是求n的因子数、先将每个数求出最小素因子、再将n的所有素因子数加1相乘。小结论:求一个数的所有因子数、先分解、n=(a^x)*(b^y)*(c^z),(a、b、c均为素数),因子数=(x+1)*(y+1)*(z+1)-1。

AC代码:输入数据很多,开始用cin果断超时了。

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <iterator>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <cctype>
#include <cfloat>
using namespace std; typedef long long LL;
const int N=1000005;
const LL II=1000000007;
const int INF=0x3f3f3f3f;
const double PI=acos(-1.0); int n,Min[N];//每一个数的最小质因数 void MIN()
{
int i,j;
for(i=2;i<N;i+=2)
{
Min[i]=2;
Min[i-1]=0;
}
for(i=3;i<N;i++)
{
if(Min[i]==0)
{
Min[i]=i;
if(i>sqrt(N*1.0)) continue;//防止越界
for(j=i*i;j<N;j+=i)
if(Min[j]==0)
Min[j]=i;
}
}
} void xiaohao()
{
int i,j,p=n,sum=1;
while(p>1)
{
int cnt=1,k=Min[p];
while(p%k==0)
{
cnt++;
p/=k;
}
sum*=cnt;
}
printf("%d %d\n",sum-1,n/Min[n]);
} int main()
{
MIN();
while(scanf("%d",&n)!=EOF)
{
xiaohao();
}
return 0;
}

FOJ 1607 Greedy division 数学题的更多相关文章

  1. FUzhou 1607 Greedy division---因子个数问题。

    Problem 1607 Greedy division http://acm.fzu.edu.cn/problem.php?pid=1607 Accept: 402    Submit: 1463T ...

  2. Polynomial Division 数学题

    https://www.hackerrank.com/contests/101hack45/challenges/polynomial-division 询问一个多项式能否整除一个一次函数.a * x ...

  3. C. Greedy Arkady

    kk people want to split nn candies between them. Each candy should be given to exactly one of them o ...

  4. 水题挑战6: CF1444A DIvision

    A. Division time limit per test1 second memory limit per test512 megabytes inputstandard input outpu ...

  5. python from __future__ import division

    1.在python2 中导入未来的支持的语言特征中division(精确除法),即from __future__ import division ,当我们在程序中没有导入该特征时,"/&qu ...

  6. USACO . Greedy Gift Givers

    Greedy Gift Givers A group of NP (2 ≤ NP ≤ 10) uniquely named friends has decided to exchange gifts ...

  7. [LeetCode] Evaluate Division 求除法表达式的值

    Equations are given in the format A / B = k, where A and B are variables represented as strings, and ...

  8. 关于分工的思考 (Thoughts on Division of Labor)

    Did you ever have the feeling that adding people doesn't help in software development? Did you ever ...

  9. Windows 10一周年更新正式版官方ISO镜像(1607)

    微软已经开始推送Win10一周年更新正式版系统,按照此前预告微软官方网站也同步推出了Win10一周年更新正式版ISO官方镜像下载,版本已经升级到最新的1607,也就是Win10 Build 1607, ...

随机推荐

  1. Week5(10月11日):国庆后补课的复杂心情

    Part I:提问  =========================== 1.说说你所知道的强类型视图HTML扩展方法. 2.请解释代码. @Html.ActionLink("链接文字& ...

  2. 快的打车 技术部 在 杭州 招聘 #年前面试 年后入职#架构师 - 内推网(neitui.me)

    快的打车 技术部 在 杭州 招聘 #年前面试 年后入职#架构师 - 内推网(neitui.me) 陈丹 (cd**@kuaidadi.com) 01-18 发布了内推 #年前面试 年后入职#架构师 • ...

  3. Cshap 使用http发起请求.

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 using System; using System.I ...

  4. HDU 1150:Machine Schedule(二分匹配,匈牙利算法)

    Machine Schedule Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  5. 01-IOSCore - NSString、NSFileManager、NSBundle、StringAndObjectConvert

    模型 1 将数据存储到硬盘,将硬盘上的数据在读回内存 2 文件存储: NSFileHandle 对文件的读写 NSData 二进制数据 NSString 表示文件路径 NSFileManager(对文 ...

  6. html:打开新的页面

    在html页面中,打开一个新的页面,有两种方式: 一.利用超链接 <a href="newurl">新页面</a> 上面代码添加了一个新链接,点击链接时会打 ...

  7. MinGW介绍与使用

    3.1:MinGW 是什么? MinGW 提供了一套简单方便的Windows下的基于GCC 程序开发环境.MinGW 收集了一系列免费的Windows 使用的头文件和库文件:同时整合了GNU ( ht ...

  8. 关于C(m,n)%p的故事

    序 遥远的\(\mod p\)(\(p\)是质数)大陆有一个恶魔:\[C(m,n)={m!\over n! (m-n)!}\] 于是大家有了各种求逆元的方法.这里MOD = p. 壹 for (int ...

  9. 【新提醒】N820 N821 android 4.2 V1.1版 - 大V综合交流区 - 360官方论坛

    http://bbs.360safe.com/forum.php?mod=viewthread&tid=3088815&extra=page%3D1%26filter%3Dtypeid ...

  10. 一步一步重写 CodeIgniter 框架 (2) —— 实现简单的路由功能

    在上一课中,我们实现了简单的根据 URI 执行某个类的某个方法.但是这种映射没有扩展性,对于一个成熟易用的框架肯定是行不通的.那么,我们可以让 框架的用户 通过自定义这种转换来控制,用 CI 的术语就 ...