Tags » Sieve

Review: Kruve Sifter for Grinder Calibration

To improve your coffee, improve your grind.

Chances are you’ve heard this advice (or some variation of it) before. And for good reason – it can save you a… 1,402 more words

Extraction

THE JUMBLIES

They went to sea in a sieve they did

In a sieve they went to sea

In spite of all their friends could say

On a winter’s morn on a stormy day… 613 more words

Poems

January 31st (I Think!)

wouldn’t you think
in this day and age
with all our technology
knowledge and monery
that we could make
each and every month
the exact same length? 36 more words

Poetry

TEACH AND GUARD THEM

Proverbs 1:8 Hear, my son, your father’s instruction,
and forsake not your mother’s teaching,
9 for they are a graceful garland for your head
and pendants for your neck. 97 more words

Writing

SPOJ - Prime Again (Solution approach)

For this problem[], the statement is fairly simple.

Given an integer N (3<=N<=2^32), you will have to find the largest prime number, that is strictly smaller than N.

1,102 more words
Number Theory

The Sieve Initiative

I have deployed the sieve.

Yes, this is as ominous as it sounds. Shudder, if you please.

In an attempt not to be overtly wordy in my first Cozy Mystery, I have soldered a fine-meshed strainer to my head. 42 more words

Author

Light OJ 1028 - Trailing Zeroes (I) [solved]

/******************************************
          Mobarak Hosen Shakil
        ICE, Islamic University
     ID: mhiceiuk(all), 29698(LOJ)
   E-mail: mhiceiuk @ (Gmail/Yahoo/FB)
 Blog: https://iuconvergent.wordpress.com
*******************************************/

#include<bits/stdc++.h>
#define sroot 1000007

using namespace std;
vector <int> primes;


int sieve()
{
    bool a;
    memset(a, 0, sizeof(a));

    for(int i = 2; i <= sroot; i++) {
        if(a[i] == 0) {
            for (int j = i + i; j <= sroot; j = j + i) {
                a[j] = 1;
            }

        }

    }
    primes.push_back(2);
    for (int i = 3; i <= sroot; i+=2) {
        if(a[i] == 0) {
            primes.push_back(i);
        }

    }

}

int main()
{
    sieve();

    int t;
    long long x, sum, k, temp, n;
    ///cout<<primes.size()<<endl;

    scanf("%d", &t);

    for (int cases = 1; cases <= t; cases++) {
        scanf("%lld", &x);
        sum = 1;
        n = sqrt(x);

        for(int i = 0; i <= primes.size() - 1 and primes[i] <= n ; i++) {

            k = 0;
            if(x < primes[i]) {
                break;
            }

            while(x % primes[i] == 0) {

                x = x / primes[i];
                k++;
            }

            sum = sum * (k + 1);

        }

        if(x > 1) sum *= 2;
        ///cout << x << endl;
        sum = sum - 1;

        printf("Case %d: %lld\n",cases, sum);

    }

}
Light OJ