zoukankan      html  css  js  c++  java
  • SGU 117 Counting

     

    117. Counting

    time limit per test: 0.5 sec. 
    memory limit per test: 4096 KB

    Find amount of numbers for given sequence of integer numbers such that after raising them to the M-th power they will be divided by K.

    Input

    Input consists of two lines. There are three integer numbers N, M, K (0<N, M, K<10001) on the first line. There are N positive integer numbers ? given sequence (each number is not more than 10001) ? on the second line.

    Output

    Write answer for given task.

    Sample Input

    4 2 50
    9 10 11 12

    Sample Output

    1
    Author: Michael R. Mirzayanov
    Resource: PhTL #1 Training Contests
    Date: Fall 2001





    SGU中难得的水题。。。。怒A。。。

     

    #include <iostream>
    #include <cstring>
    #include <cstdio>
    #include <cmath>

    using namespace std;

    int prim[11000];
    int sigK[11000],sigA[11000];

    int main()
    {
        int n,m,k;
        cin>>n>>m>>k;
        memset(prim,-1,sizeof(prim));
        prim[1]=prim[0]=0;
        for(int i=2;i<=sqrt(11000);i++)
        {
            if(prim==0continue;
            for(int j=2*i;j<11000;j+=i)
            {
                prim[j]=0;
            }
        }
        for(int i=0;i<11000;i++)
        {
            if(prim!=0)
            {
                while(k%i==0)
                {
                    k/=i;
                    sigK++;
                }
            }
        }
        int ans=0;
        for(int i=0;i<n;i++)
        {
            int a;
            cin>>a;
            memset(sigA,0,sizeof(sigA));
            for(int j=0;j<11000;j++)
            {
                if(prim[j]!=0)
                {
                    while(a%j==0)
                    {
                        a/=j;
                        sigA[j]++;
                    }
                    sigA[j]*=m;
                }
            }
            bool OK=true;
            for(int j=0;j<11000;j++)
            {
                if(sigK[j])
                {
                    if(sigA[j]<sigK[j])
                    {
                       OK=false;
                       break;
                    }
                }
            }
            if(OK) ans++;
        }
        cout<<ans<<endl;
        return 0;
    }
    * This source code was highlighted by YcdoiT. ( style: Codeblocks )
  • 相关阅读:
    Mac上搭建Hadoop环境(3) — Hive下载及安装
    Mac上搭建Hadoop环境(2) — Hadoop下载及安装
    Mac上搭建Hadoop环境(1) — 虚拟机的安装及SSH免密设置
    Mac上ssh localhost免密失败该如何解决
    Java8 Lambda 之 Collection Stream
    Java 集合Collection——初学者参考,高手慎入(未完待续)
    Java注解Annotation(一)
    ubuntu下安装和破解navicat的方法
    java I/O流类概述
    List元素为泛型时的注意事项
  • 原文地址:https://www.cnblogs.com/CKboss/p/3350886.html
Copyright © 2011-2022 走看看