View Code of Problem 119

#include<iostream>
#include<algorithm>
using namespace std;
bool p[1000555] = {0};
int num[1000555] = { },op = 1;
void find();
int main(){
	int n;
	find();
	while(~scanf("%d",&n)){
		int f = 0;
		if(n == 1)f = 1;
		else{
			if(num[n]!=0)f = 1;
		}
		if(f){
			printf("Case #%d: I'm richer than any one",op);	
		}else{
			printf("Case #%d: What a fxcking day",op);
		}
		op++;
		printf("\n");
	}
	return 0;
} 
void find(){
	for(int i = 2;i<1000001;i++){
		if(p[i] == false){
			num[i] = i;
			for(int j = i*2;j<1000001;j+=i){
				p[j] = true;
			}
		}
	}
}





Double click to view unformatted code.


Back to problem 119