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. 技能学习经验与C语言学习调查

    技能学习经验与C语言学习调查 前言 要说的话,这还是我第一次写博客.不论是为了作业也好,为了将来的学习工作也好,写博客都是必不可少的,也算是个自我提升的途径吧.不过第一次写博客,就用从来没听说过的ma ...

  2. (89c51)16x16点阵屏幕的实现

    基本组件是一个51单片机,一个74154译码器,四个MATRIX-8X8. 考虑到单片机引脚有限,所以使用P0口和P2口的总共16根引脚选择列,而P1口的低4位接译码器,译出的一个低电平选择行.所以图 ...

  3. string 数字序列大小比较

    string 数字序列大小比较 string.compare string a = "022"; string b="1"; 比较结果 '022' < ' ...

  4. 各种编码之间的关系以及getBytes的使用

    编码基础知识参考http://my.oschina.net/chape/blog/201725 我对此作了简单的概括 iso8859-1 (通常叫做Latin-1) 属于单字节编码,最多能表示的字符范 ...

  5. DataGrid 导出数据到 Excel

    Private Sub GridToExl_Click() On Error Resume Next If DataGrid1.Columns.Count = 0 Then MsgBox " ...

  6. js获取计算的样式(非行间样式)

    function getStyle(obj, attr){ if(obj.currentStyle){ style = obj.currentStyle[attr]; //兼容IE8以下 }else{ ...

  7. 主机连不上虚拟机中的Redis的原因分析、以及虚拟机网络配置

    1. 网络最好是桥接方式.我之前用的是"网络地址转换(NAT)",导致虚拟机里用命令ifconfig得到的ip是10.0.2.15,好奇怪的感觉,然后在真实机上一直连不上.有的说用 ...

  8. Github命令详解

    Git bash: ***创建本地版本库: $ cd d: $ mkdir git $ cd git $ mkdir test $ git init   //初始化本地库 ***创建文件并添加到版本库 ...

  9. Webdriver常用的元素定位

    Webdriver常用定位元素的方法有以下八种: id.name.class name.tag name.link text.partial link text.xpath.class selecto ...

  10. python 基础学习-总结1

    1.Python 简介 易学易懂,语法简单 不需编译,即可运行 比其他语言更简洁 不需要管理内存 1.1 什么是Python? python 是由Guido.van.Rossum于1989年始创,其根 ...