• 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 )
  • 相关阅读:
    【JLOI 2015】城池攻占
    【BalticOI 2004】Sequence
    罗马游戏
    《STL源码剖析》STL迭代器分类
    《Effective C++》模版与泛型编程
    《Effective C++》继承与面向对象设计
    《Effective C++》实现 章节
    [C++]const_cast,dynamic_cast,reinterpret_cast,static_cast转型
    [C++]default constructor默认构造函数
    [C++]union联合体总结
  • 原文地址:https://www.cnblogs.com/CKboss/p/3350886.html
Copyright © 2020-2023  润新知