zoukankan      html  css  js  c++  java
  • 1049. Brave Balloonists

    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

    inputoutput
    1
    2
    6
    1
    3
    1
    1
    1
    1
    1
    
    9
    
    Problem Author: Stanislav Vasilyev Problem Source: Ural State University collegiate programming contest (25.03.2000)
    ***************************************************************************************
    求因子的个数=连乘(ai+1);ai为质因子的个数。
    ***************************************************************************************
     1 #include<iostream>
     2 #include<cstring>
     3 #include<string>
     4 #include<cstdio>
     5 #include<cmath>
     6 using namespace std;
     7 int su[10003];
     8 bool  p[10003];
     9 int ks,sm;
    10 int sum[10003];
    11 void  find(int x)
    12 {
    13     int m=x;
    14     m+=x;
    15     while(m<=10001)
    16      {
    17          p[m]=true;
    18          m+=x;
    19      }
    20 }
    21 void  sushu()
    22 {
    23     for(int iv=2;iv<=10001;iv++)
    24      {
    25          if(!p[iv])
    26          {
    27               find(iv);
    28               su[++ks]=iv;
    29          }
    30 
    31      }
    32 }
    33 int main()
    34 {
    35     int a;
    36     ks=0;
    37     int i,ds;
    38     memset(p,false,sizeof(p));
    39     memset(su,0,sizeof(su));
    40     sushu();
    41     memset(sum,0,sizeof(sum));
    42     for(i=1;i<=10;i++)
    43      {
    44          cin>>a;
    45          ds=1;
    46          while(a>1)
    47          {
    48              while(a%su[ds]==0&&a>1&&su[ds]<=a)
    49                {
    50                    a=a/su[ds];
    51                    ++sum[ds];
    52                 }
    53             ds++;
    54          }
    55      }
    56     sm=1;
    57     for(i=1;i<=ks;i++)
    58      {
    59          //cout<<sum[i]<<endl;
    60     sm=sm*(sum[i]+1);
    61     //cout<<num%10<<endl;
    62     }
    63     cout<<sm%10<<endl;
    64     return 0;
    65 }
    View Code
  • 相关阅读:
    android添加文件打开方式以及参数传递
    Android文字图片写入CSV(Base64)并分享
    Fragment嵌套Fragment要用getChildFragmentManager
    Android数据库存取图片以及转换成缩略图
    2015已经过去三分之一了
    GridView和ListView简单使用
    WPF处理Windows消息
    90后码农的北京求职之旅
    排序算法复习—快速排序
    排序算法复习—归并排序
  • 原文地址:https://www.cnblogs.com/sdau--codeants/p/3251031.html
Copyright © 2011-2022 走看看