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. (ASP.NET )去除字符串中的HTML标签

    string strDoContent = "执行增加<a href="/AdminCX/Admin_CompanyDetail.aspx?CompanyGuid=cd8e1 ...

  2. Openjudge-NOI题库-出书最多

    描述 假定图书馆新进了m(10 ≤ m ≤ 999)本图书,它们都是由n(2 ≤ n ≤ 26)个作者独立或相互合作编著的.假设m本图书编号为整数(1到999),作者的姓名为字母('A'到'Z'),请 ...

  3. sim808模块收发送短信

    一,简介 SIM 808发送短信分text模式和PDU模式.text模式已ascii码发送短信,这种模式比较简单,发送命令AT+CMGF=1就可以发送短信,而PDU模式比较复杂,首先发送命令AT+CM ...

  4. CVE-2016-0143 漏洞分析(2016.4)

    CVE-2016-0143漏洞分析 0x00 背景 4月20日,Nils Sommer在exploitdb上爆出了一枚新的Windows内核漏洞PoC.该漏洞影响所有版本的Windows操作系统,攻击 ...

  5. 语言总结—C/C++

    参考<程序员面试宝典> 1. 基本概念 1.1 赋值语句 例1. 按位与操作,例如:a=3,b=3,a&b值等于 0011 & 0011 结果还是0011,那么值还是3: ...

  6. JavaBean的属性变量名前两个字母大小写问题

    Java属性命名规范! 一般情况下.Java的属性变量名都已小写字母开头,如:userName,showMessage等,但也存在着特殊情况,考虑到一些特定的有意思的英文缩略词如(USA,XML等), ...

  7. caffe编译出现的新错误

    1.include/caffe/blob.hpp:9:34: fatal error: caffe/proto/caffe.pb.h: No such file or directory #inclu ...

  8. 微信小程序官方demo学习

    最近微信小程序很火,很喜欢那种轻应用,用完就走的理念.于是,下载好微信开发者工具,学习一下官方demo. 体验下来,有类似react和vue的感觉,dom类似react那种组件的,data-bindi ...

  9. 简单的 Android 拍照并显示以及获取路径后上传

    简单的 Android 拍照并显示以及获取路径后上传 Activity 中的代码,我只贴出重要的事件部分代码 public void doPhoto(View view) { destoryBimap ...

  10. 定时器 QuartZ Cron表达式

    CronTrigger CronTriggers往往比SimpleTrigger更有用,如果您需要基于日历的概念,而非SimpleTrigger完全指定的时间间隔,复发的发射工作的时间表. CronT ...