D. Taxes

链接:https://codeforces.com/problemset/problem/735/D

Mr. Funt now lives in a country with a very specific tax laws. The total income of mr. Funt during this year is equal to n (n ≥ 2) burles and the amount of tax he has to pay is calculated as the maximum divisor of n (not equal to n, of course). For example, if n = 6 then Funt has to pay 3 burles, while for n = 25 he needs to pay 5 and if n = 2 he pays only 1 burle.

As mr. Funt is a very opportunistic person he wants to cheat a bit. In particular, he wants to split the initial n in several parts n1 + n2 + ... + nk = n (here k is arbitrary, even k = 1 is allowed) and pay the taxes for each part separately. He can't make some part equal to 1 because it will reveal him. So, the condition ni ≥ 2 should hold for all i from 1 to k.

Ostap Bender wonders, how many money Funt has to pay (i.e. minimal) if he chooses and optimal way to split n in parts.

Input

The first line of the input contains a single integer n (2 ≤ n ≤ 2·109) — the total year income of mr. Funt.

Output

Print one integer — minimum possible number of burles that mr. Funt has to pay as a tax.

Examples

input

Copy

4

output

Copy

2

input

Copy

27

output

Copy

3

题解:哥德巴赫猜想:任意一个大于2的偶数可以拆成两个素数的和,任意一个大于7的奇数可以拆成三个素数的和。

代码:

#include<bits/stdc++.h>
using namespace std;
long long n,t,g,k,l,o,s,r,ans,ss,max1=0;
bool f(long long n)
{
	k=sqrt(n);
    int flag=1;
    for(int i=2;i<=k;i++)
    {
    	if(n%i==0)
    	{
    		return false;
    	}
    }
    return true;
} 
int main()
{
    cin>>n;
    if(f(n)==1)
    cout<<1;
    else if(n%2==0||f(n-2)==1)
    cout<<2;
    else if(n%2==1&&n>7)
    cout<<3;
}

 

alter table sdm.sdm_gb_flow_cost_record_raw_a_d on cluster 'default_cluster' drop partition ('idm_handwork_ito_business_flow_a_d', '2025-08-25') insert into sdm.sdm_gb_flow_cost_record_raw_a_d(belong_month, region_area, customer_name, customer_type, customer_master_name, company_settlement_license_name, project_name, product_bu, product_name, product_package_name, total_settlement_amount, taxes, field_map, table_source, source_dt, dt) select toYYYY_MM(belong_month) as belong_month, service_item_region as region_area, customer_name as customer_name, client_type as customer_type, customer_master_name as customer_master_name, company_settlement_license_name as company_settlement_license_name, project_name as project_name, product_bu as product_bu, product_name as product_name, ifNull(product_package_name, '') as product_package_name, toDecimal256OrDefault(total_settlement_amount, 20) as total_settlement_amount, toDecimal256OrDefault(taxes, 20) as taxes, map( 'id', toString(id), 'bill_no', toString(bill_no), 'service_item_region', toString(service_item_region), 'client_type', toString(client_type), 'project_name', toString(project_name), 'bill_month', toString(bill_month), 'bill_date', toString(bill_date), 'invoice_month', toString(invoice_month), 'tax_rate', toString(tax_rate), 'tax_total_settlement_amount', toString(tax_total_settlement_amount), 'create_by', toString(create_by), 'created_at', toString(created_at), 'updated_by', toString(updated_by), 'updated_at', toString(updated_at), 'customer_level', toString(customer_level) ) as field_map, 'idm_handwork_ito_business_flow_a_d' as table_source, t1.dt as source_dt, '2025-08-25' FROM ods.ods_handwork_ito_business_flow_a_d AS t1 INNER JOIN dim.dim_finance_close_account_all_dt AS t2 ON t1.dt = t2.dt and t2.table_name = 'idm_handwork_ito_business_flow_a_d' WHERE (t1.dt IN (SELECT dt FROM dim.dim_finance_close_account_all_dt)) AND belong_month between t2.start_month and t2.end_month settings max_threads = 1 clickhouse,这些sql的含义
最新发布
08-27
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值