1049. Brave Balloonists

Time limit: 2.0 second
Memory limit: 64 MB
Ten mathematicians are flying on a balloon over the Pacific ocean. When they are crossing the equator they decide to celebrate this event and open a bottle of champagne. Unfortunately, the cork makes a hole in the balloon. Hydrogen is leaking out and the balloon is descending now. Soon it will fall into the ocean and all the balloonists will be eaten by hungry sharks.
But not everything is lost yet. One of the balloonists can sacrifice himself jumping out, so that his friends would live a little longer. Only one problem still exists: who is the one to get out. There is a fair way to solve this problem. First, each of them writes an integer ai not less than 1 and not more than 10000. Then they calculate the magic number N that is the number of positive divisors of the product a1*a2*…*a10. For example, the number of positive integer divisors of 6 is 4 (they are 1,2,3,6). The hero (a mathematician who will be thrown out) is determined according to the last digit of N. Your task is to find this digit.

Input

Input contains ten integer numbers (each number is in separate line).

Output

Output a single digit from 0 to 9 — the last digit of N.

Sample

input output
1
2
6
1
3
1
1
1
1
1
9

题意:

十个数学家乘气球飞行在太平洋上空。当横越赤道时,他们决定庆祝一下这一壮举。于是他们开了一瓶香槟。不幸的是,软木塞在气球上打了一个洞,氢气泄漏,气球开始下降,眼看就要落入海中,所有人将要被鲨鱼吃掉。

但是尚有一线生机--若其中一人牺牲自己跳下去的话,那他的朋友们还能多活一会儿。但仍然有一个问题存在--谁跳下去?所以他们想了一个非常公平的办法来解决这个问题--首先,每人写一个整数ai(1≤ai≤10000);然后计算出a1×a2×a3×a4×……×a10的积的约数的个数N。例如,6的约数有4个(1、2、3、6),则N为4。这位牺牲自己的英雄将由N的个位数来决定(编号为N的个位数加1的人要跳下去)。你的任务是求出N的个位。

思路:进行的标准分解,根据(标准分解):任何一个自然数都可以被分解成有限个素数相乘的形式

 #include<iostream>
#include<cstdio>
#include<cstring>
using namespace std; bool ks[]= {true};
int kiss[]={};
int ss[]= {};
int number=; int main()
{
// freopen("input.txt","r",stdin);
memset(ks,true,sizeof(ks));
ks[]=true;
int i=;
ss[]=;
while(i<=)
{
if(!ks[i])
{
i++;
continue;
}
ss[number++]=i;
for(int j=; i*j<=; j++)
{//求出小于10001的所有素数
ks[i*j]=false;
}
i++;
}
int s=;
while(s)
{//录入数据
int a;
cin>>a;
while()
{//处理录入的a,对a进行标准分解
if(ks[a])
{
kiss[a]++;
break;
}
i=;
while(i<number)
{
if(a%ss[i]==)
{
kiss[ss[i]]++;
a=a/ss[i];
}
i++;
}
}
s--;
}
int sgin=;
for(i=; i<=; i++)
{//统计余数的个数
sgin*=(kiss[i]+);
sgin%=;
if(sgin==)
break;
}
cout<<sgin<<endl;
return ;
}

ural 1049. Brave Balloonists(标准分解式,数论)的更多相关文章

  1. URAL 1139 City Blocks(数论)

    The blocks in the city of Fishburg are of square form. N avenues running south to north and Mstreets ...

  2. URAL1049. Brave Balloonists

    1049 求约数的个数 质因子数的个数+1相乘 #include <iostream> #include<cstdio> #include<cstring> #in ...

  3. ural 1356. Something Easier(数论,哥德巴赫猜想)

    1356. Something Easier Time limit: 1.0 secondMemory limit: 64 MB “How do physicists define prime num ...

  4. URAL题解三

    URAL题解三 URAL 1045 题目描述:有\(n\)个机场,\(n-1\)条航线,任意两个机场有且只有一种方案联通.现有两个恐怖分子从\(m\)号机场出发,第一个人在机场安装炸弹,乘坐飞机,引爆 ...

  5. URAL 1104 Don’t Ask Woman about Her Age(数论)

    题目链接 题意 : 给你一个数,未知进制,然后让你从2到36进制中找出一个最小的进制K,满足给你的这个数作为k进制时能够整除k-1. 思路 : 有一个公式,(a*b^n)mod(b-1)=a: 给定你 ...

  6. URAL 1430. Crime and Punishment(数论)

    题目链接 题意 :给你a,b,n,让你找出两个数x,y,使得n-(a*x+b*y)最小. 思路 : 分大小做,然后枚举a的倍数 #include <stdio.h> #include &l ...

  7. URAL 1355. Bald Spot Revisited(数论)

    题目链接 题意 : 一个学生梦到自己在一条有很多酒吧的街上散步.他可以在每个酒吧喝一杯酒.所有的酒吧有一个正整数编号,这个人可以从n号酒吧走到编号能整除n的酒吧.现在他要从a号酒吧走到b号,请问最多能 ...

  8. URAL 1133 Fibonacci Sequence(数论)

    题目链接 题意 :给你第 i 项的值fi,第 j 项的值是 fj 让你求第n项的值,这个数列满足斐波那契的性质,每一项的值是前两项的值得和. 思路 :知道了第 i 项第j项,而且还知道了每个数的范围, ...

  9. Ural 2003: Simple Magic(数论&思维)

    Do you think that magic is simple? That some hand-waving and muttering incomprehensible blubber is e ...

随机推荐

  1. Func,Action 的介绍

    Func,Action 的介绍 Func是一种委托,这是在3.5里面新增的,2.0里面我们使用委托是用Delegate,Func位于System.Core命名空间下,使用委托可以提升效率,例如在反射中 ...

  2. centos7安装mariadb后无法启动的问题

    MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可.开发这个分支的原因之一是:甲骨文公司收购了MySQL后,有将MySQL闭源的潜在风险,因此社区采用分支的方 ...

  3. <hdu - 1280> 前M大的数 (注意其中的细节)

    这是杭电hdu上的链接http://acm.hdu.edu.cn/showproblem.php?pid=1280  Problem Description: 还记得Gardon给小希布置的那个作业么 ...

  4. Android服务

    开启服务 (startservice) 服务一旦开启与调用者没有任何的关系 , 调用着的activity 即便是退出了 也不会影响 后台的service的运行. 在activity里面 不能去调用服务 ...

  5. spring mvc 实现文件上传下载

    /** * 文件上传 * @param pictureFile */ @RequestMapping("/reportupload") public ResponseInfo up ...

  6. 反射机制(reflection)动态相关机制

    功能:动态获取类的信息以及动态调用对象的方法. Java反射机制主要提供了以下功能: 1.在运行时判断任意一个对象所属的类. 2.在运行时构造任意一个类的对象. 3.在运行时判断任意一个类所具有的成员 ...

  7. lucene Filter过滤器

    摘自:http://iamyida.iteye.com/blog/2199368 1.TermFilter:就是按照Term去过滤,跟TermQuery类似: Filter filter = new ...

  8. javascript DOM对象(1)

    0.文档对象模型DOM(Document Object Model)定义访问和处理HTML文档的标准方法. DOM 将HTML文档呈现为带有元素.属性和文本的树结构(节点树). 将HTML代码分解为D ...

  9. 查询被收录页面中的死链接 By SEO

    朋友说他的站挂了,想知道被收录的页面有多少是死链,于是我就想了一下流程,从Site获得收录数量当然是不精准的,不过也没有更好的地了,真实的收录只有搜索引擎数据库里面才有... 查询被收录页面的状态码, ...

  10. java复习 --集合类

    List接口:可以存放重复内容: set接口:不能存放重复内容,重复内容依靠hashcode和equal两个方法来区分: Queue:队列: SortedSet接口:对集合中的数据进行排序:   Li ...