• 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
  • 相关阅读:
    详解Github的.gitignore忽略文件+.gitignore不生效解决方案+生产配置大奉送
    npm install报错 npm ERR! 的四种解决办法
    公司内部一次关于OOM故障复盘分享
    ubuntu16.04 安裝mysql5.7
    git formatpatch打分支(转载)
    通过修改包名解决引用easyExcel的poi版本冲突问题(转载)
    ASP.NET Core从2.1 > 3.1后出现 [The JSON value could not be converted to System.Nullable]错误 IT苦行僧
    apache2 修改配置文件提权
    linux motd提权
    python 多进程+多线程——子进程开多线程
  • 原文地址:https://www.cnblogs.com/sdau--codeants/p/3251031.html
Copyright © 2020-2023  润新知