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

By |2017-04-07T22:11:48+00:00December 17th, 2016|Categories: C/C++, Programming|Tags: , , , , , , , , |

#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; }