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 )
  • 相关阅读:
    OpenGL简介及编程入门
    大数阶乘 我的ACM的第一步!
    解释Windows7“上帝模式”的原理
    斯特林[striling]公式(求阶乘(n!)的位数)
    VC中借助内嵌资源实现Flash动画播放
    VC MFC 精品文章收集!
    这应该是UFC有史以来最快的KO记录了
    深以为然
    PS3欧洲延期!全球同步发售幻想破灭
    Windows Vista RC1 NVIDIA drivers include OpenGL ICD
  • 原文地址:https://www.cnblogs.com/CKboss/p/3350886.html
Copyright © 2011-2022 走看看