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. iOS SDWebImage的使用

    现在把代码贴出来,供大家参考.尤其是新手,看完这篇博客,图片缓存so easy.最后有demo供大家下载,先学习. 第一步,下载SDWebImage,导入工程.github托管地址https://gi ...

  2. KMP 算法 学习 整理

    我自己整理的KMP算法的PDF文件:http://pan.baidu.com/s/1o8yKIi2提取密码:8291 别的就不多说啥了,感谢来自海子 博客园的 资料--

  3. Asp.net简单代码设置GridView自适应列宽不变形

    动态绑定的GridView由于列数不固定,而列又太多,是要自定设置gridView的宽度 //在GridView的行数据绑定完的事件中设置 protected void gvObjectList_Ro ...

  4. java实现的简单词法分析器

    一个简单的词法分析器 词法分析(Lexical Analysis) 是编译的第一阶段.词法分析器的主要任务是读入源程序的输入字符.将他们组成词素,生成并输出一个词法单元序列,每个词法单元对应一个词素. ...

  5. 面试题-Java基础-开发环境

    1.什么是Java虚拟机?为什么Java被称作是“平台无关的编程语言”? Java虚拟机是一个可以执行Java字节码的虚拟机进程.Java源文件被编译成能被Java虚拟机执行的字节码文件.Java被设 ...

  6. emmet 教程 emmet快捷键大全

    Emmet的前身是大名鼎鼎的Zen coding,如果你从事Web前端开发的话,对该插件一定不会陌生.它使用仿CSS选择器的语法来生成代码,大大提高了HTML/CSS代码编写的速度,比如下面的演示: ...

  7. 12C RMAN 备份参考

    12C引进了pdb的概念,使得rman的恢复相对来说复杂了一些,这里对pdb的常规备份和恢复进行了简单测试,供大家参考 1.cdb启动和pdb关系测试 [oracle@xifenfei tmp]$ s ...

  8. bit、byte、k

    bit(位/比特位):一个二进制数据0/1 byte(字节):简称B:1byte=8bit:一个英文字符占用1byte,一个汉字占用2byte k:1K=1024B M:1M=1024K

  9. 绿色astah简体中文版6.8

    astah是一个UML建模的好工具,绿化后,现在开始将它汉化. 欢迎大家提出汉化翻译不当的地方,在本帖子留言. 需要汉化的内容较多,我会逐渐发布汉化更完全的版本. 说明:astah6.8需要使用jre ...

  10. java中String类型的相关知识

    String类方法整理说明: ·Length()用来求字符串的长度,返回值为字符串的长度: ·charAt()取该字符串某个位置的字符,从0开始,为char类型: ·getChars()将这个字符串中 ...