https://i0.wp.com/eblogarithm.com/wp-content/uploads/2016/12/Codeforces-Round-382-Div-2-problem-D-Taxes-Solution-in-CC1.png?fit=640%2C360

Codeforces Round #382 (Div. 2), problem: (D) Taxes Solution in C/C++

#include<stdio.h>
int isprime(int n);
int main(){
	int n;
	scanf("%d",&n);
	if(n%2==1){
		if(isprime(n)){
			printf("1");
		}else{
			printf("%d",3-isprime(n-2));
		}
	}else{
		printf("%d",1+(n>2));
	}
	return 0;
}
int isprime(int n){
	int i,j;
	for(i=2;i*i<=n;i++){
		if(n%i==0){
			return 0;
		}
	}
	return 1;
}
(Visited 61 times, 1 visits today)



There are no comments

Add yours

Leave a Reply

%d bloggers like this: