View Code of Problem 119

#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>

using namespace std;

int a[10000000]={0};
void init()
{
    for(int i=2;i<10000000;i++)
    {
        if(a[i]==1) continue;
        for(int j=i*2;j<10000000;j+=i)
            a[j]=1;
    }
}
int main()
{
    int n,i=1;
    init();
    while(cin>>n)
    {
        if(a[n]==0)
        {
            printf("Case #%d: ",i);
            cout<<"I'm richer than any one\n";
        }
        else
        {
            printf("Case #%d: ",i);
            cout<<"What a fxcking day\n";
        }
        i++;
    }
}

Double click to view unformatted code.


Back to problem 119