zoukankan      html  css  js  c++  java
  • POJ 2603 Brave balloonists

    Brave balloonists
    Time Limit: 1000MS   Memory Limit: 65536K
    Total Submissions: 4546   Accepted: 1924

    Description

    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 integer 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 file contains ten numbers separated by a space.

    Output

    Output file should consist of a single digit from 0 to 9 - the last digit of N.

    Sample Input

    1
    2
    6
    1
    3
    1
    1
    1
    1
    1
    

    Sample Output

    9

    Source

    求10个数相乘 约数个数%10 

    若正整数n可分解为(p1^a1)*(p2^a2)*…*(pk^ak)
    其中pi为两两不同的素数,ai为对应指数
    n的约数个数为(1+a1)*(1+a2)*….*(1+ak)

    #include <iostream>
    #include <stdio.h>
    #include <cmath>
    #include <string.h>
    using namespace std;
    bool hash[10000];
    bool is_p(int &n)
    {
        int i,m=sqrt(double(n));
        for(i=3;i<=m;i+=2)
         if(n%i==0)
           return false;
        return true;
    }
    int rc[1300],l;
    void set()
    {
         int i,j;
        for(i=4;i<10000;i+=2)
          hash[i]=1;
        for(i=3;i<10000;i+=2)
           if(is_p(i))
             for(j=i+i;j<10000;j+=i)
               hash[j]=1;
        j=0;
        for(i=2;i<10000;i++)
         if(!hash[i])
          rc[j++]=i;
        l=j;
    }
    int p[100],q[100];
    int main()
    {
        set();
        memset(hash,0,sizeof(hash));
        int i;
        int n;
        int l=0,k,j;
        for(i=0;i<10;i++)
        {
            scanf("%d",&n);
            k=0;
            while(n!=1)
            {
                while(n%rc[k]==0)
                {
                    if(!hash[rc[k]])
                    {
                        p[l]=rc[k];
                        q[l]=2;
                        hash[rc[k]]=1;
                        l++;
                    }
                    else
                    {for(j=0;j<l;j++)
                        {
                          if(p[j]==rc[k])
                            {q[j]++;break;}
                        }
                    }
                 n=n/rc[k];
                }
              k++;
            }
        }
        int s=1;
        for(i=0;i<l;i++)
          {
             s=(s*q[i])%10;
          }
        printf("%d\n",s);
        return 0;
    }

  • 相关阅读:
    如何在百度网盘中批量添加好友,批量创建群组,导出群链接等
    批量对百度网盘好友及群组发文字消息及分享文件
    百度网盘禁止查看别人分享主页的资源收集解决办法
    C#调用windows API实现 smallpdf客户端程序进行批量压缩
    邓西百度网盘目录导出工具
    .net sqlite 内存溢出 问题的分析与解决。
    移动呼死你防护业务白名单批量导入工具
    如何拦截电话轰炸、短信轰炸
    以技术原理入手从根本上拦截屏蔽解决响一声电话呼死你炸你妹电话轰炸短信轰炸,远离电话短信骚扰
    邓西百度网盘批量分享工具
  • 原文地址:https://www.cnblogs.com/372465774y/p/2602644.html
Copyright © 2011-2022 走看看