Taxes

本文探讨了一位名叫富特先生的角色,他居住在一个有特殊税法的国家,税款由年收入的最大除数决定。富特先生试图通过将年收入拆分为多个大于2的部分来减少税收。文章提供了示例和一个简单的代码片段来确定当收入为素数、偶数或接近素数时的最少支付税款。Ostap Bender则在寻找富特先生能支付的最低金额的方法。
摘要由CSDN通过智能技术生成

Taxes

Mr. Funt now lives in a country with a very specific tax laws. The total income of mr. Funt during this
富特先生现在住在一个有着非常具体税法的国家。先生的总收入。在此期间

year is equalton(n >= 2 ) burles and the amount of tax he has to pay is calculated as the
年为相等年(n>=2),他必须缴纳的税额按

maximum divisor of n (not equal to n , of course). For example, ifn = 6 then Funt has to pay 3
N的最大除数(当然不等于n)。例如,IFN=6,那么Funt必须支付3

burles, while for n = 25 he needs to pay5andifn = 2 he pays only 1 burle.
伯勒斯,而在25岁时,他只需付1英镑。

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 partsn1 + n2+ … + Nk: = n (here k is arbitrary, evenk = 1 is allowed) and pay
初始n为1+n2+.+nk:=n(这里k是任意的,Evenk=1是允许的)并支付

the taxes for each part separately. He can’t make some part equal to 1 because it will reveal him. So,
每个部分的税收分开。他不能让某个部分等于1,因为这会暴露他。所以,

the conditionni > = 2 should hold for alli from1 to k .
条件ni>=2应适用于从1到k的alli。

Ostap Bender wonders, how many money Funt has to pay (i.e. minimal) if he chooses and optimal
OstapBender想知道,如果Funt选择和最优的话,他需要支付多少钱(也就是最低限度)?

way to split n in parts.
把n分成几个部分的方法。

一个非素偶数能分成两个质数
一个非素质数能分成2与一个质数或这分成三个质数
如果发现反例偷偷告诉我,我给你转20


bool prime(int n)
{
    if (n<2)return 0;
        for (int i = 2; i*i <=n ; ++i) {
            if (n%i==0)return 0;
        }
       return 1;

}
    int main() {
     int n;
     cin>>n;
     if(prime(n))cout<<1<<endl;
     else if(n%2==0)cout<<2<<endl;
     else if (prime(n-2))cout<<2<<endl;
     else cout<<3<<endl;
     return 0;
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值