Codeforces Round #382 (Div. 1) B. Taxes

PMAC上位机通信原理(C#) 基础是引用 两个 ODT dll 原理是先注册到communication.AsyncDataAvailable事件中去 if (bSuccess1) { communication.AsyncDataAvailable += communication_AsyncDataAvailable; } bool bSuccess2 = communication1.GPAsciiConnect(strIP, iPort, strName, strPassword); i 阅读详情


B. Taxes
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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 partsn1 + 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
4
output
2
input
27
output
3

题意:funt的年收入是n元,交税的费用=n的最大因数(n自身除外),现在他想逃税,把n拆成任意份,但是每一份不能是1,问他最少要交多少钱的税收。

思路:其实这个我楞是没想出来,上网翻了一下题解,原来一个大于2偶数必定能拆成两个素数相加,那么这道题就很简单了,只有几种情况,如果n是2那么答案就是1,如果n是偶数但大于2,那么答案就是2,如果n是奇数且n是素数答案就是1,如果n是奇数但n不是素数n-2是素数的话,答案就是2,如果n是奇数但n不是素数也不是素数的话,答案就是3。下面给代码:

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
#include<queue>
#include<string>
#include<functional>
typedef long long LL;
using namespace std;
#define maxn 105
#define ll l,mid,now<<1
#define rr mid+1,r,now<<1|1
#define lson l1,mid,l2,r2,now<<1
#define rson mid+1,r1,l2,r2,now<<1|1
#define pi acos(-1.0)
#define inf 0x3f3f3f3f
const int mod = 1e9 + 7;
int main()
{
	LL n;
	while (~scanf("%lld", &n))
	{
		if (n == 2){
			printf("1\n");
		}
		else if (n % 2){
			bool jud1 = false, jud2 = false;
			for (int i = 2; i <= sqrt(n); i++){
				if (!(n%i)){
					jud1 = true;
					break;
				}
			}
			n -= 2;
			for (int i = 2; i <= sqrt(n); i++){
				if (!(n%i)){
					jud2 = true;
					break;
				}
			}
			if (!jud1)
				printf("1\n");
			else if (jud1&&jud2)
				printf("3\n");
			else
				printf("2\n");
		}
		else
			printf("2\n");

	}
}



AI驱动视频剪辑自动化:cutcli命令行工具重塑工作流 视频剪辑自动化是提升内容生产效率的关键技术,其核心原理在于通过程序化指令替代手动操作,将创意执行过程代码化。这项技术的价值在于能够将创作者从重复性劳动中解放,实现批量化、标准化的视频内容生产,尤其适用于社交媒体运营、产品宣传等高频产出场景。通过封装专业软件(如剪映/CapCut)的底层草稿格式,自动化工具在保证工业级渲染质量的同时,提供了可编辑的中间态,为AI智能体(Agent)与生产工具的结合提供了清晰接口。本文以cutcli为例,深入探讨了如何通过命令行工具和AI助手,构建从自然语言指令到可编辑视频草稿 阅读详情

相关推荐

GIS坐标系转换以及空间校正和地理配准

许多小伙伴都对坐标系,投影这类问题迷迷糊糊,我之前也一样,现在总结一下。 坐标系的转换1.为什么要进行坐标系的转换?2. 不同坐标系的介绍1.地理坐标系我国常见的地理坐标(1).北京54坐标系(2).西安80坐标系(3).WGS-84坐标系(4).大地2000坐标系2.投影坐标系我国常用的投影坐标系(1) UTM投影(2) 高斯-克吕格投影(3) 兰伯特投影(4) 阿尔伯斯投影投影坐标系的选择3. 坐标系的转换1.已知坐标系之间的转换1.1 两坐标系的参考椭球相同1.2 两坐标系的参考椭球不一致,但是GIS

m0_47258611的博客 8913

昨天真香了,今天继续补 codeforces/problem/735/D (数学+哥德巴赫猜想)

http://codeforces.com/problemset/problem/735/D D. Taxes time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Mr. Funt now lives in a country with a...

FOWng_lp的博客 286

相机标定原理与张氏标定法

这里写自定义目录标题欢迎使用Markdown编辑器新的改变功能快捷键合理的创建标题,有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants创建一个自定义列表如何创建一个注脚注释也是必不可少的KaTeX数学公式新的甘特图功能,丰富你的文章UML 图表FLowchart流程图导出与导入导出导入 欢迎使用Markdown编辑器 你好! 这是你第一次使用 Markdown编辑器 所展示的欢迎页。如果你想学习如何使用Mar

heeweii的博客 2280

codeforces 230B T-primes 解题报告 数论+素数

题目: B. T-primes time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output We know that prime numbers are positiv

xiaoli_nu的博客 614

simulink中无迹卡尔曼(UKF)模块使用

simulink的UKF模块简单说明

qq_41059950的博客 2820

AI赋能传染病建模:从数据到动力学模型的本地实践指南

这次我们来看一个将 AI 与传染病动力学建模结合的前沿方向。想象一下,你手头有一份流感爆发的病例数据,传统的建模方法可能需要复杂的微分方程和大量的手动调参,而 AI 模型能否直接从数据中“学习”出传播规律,甚至自动跑通整个建模流程?这正是当前研究的热点。根据《Nature》的最新综述,人工智能正在重塑传染病流行病学建模,从参数推断、趋势预测到多源数据融合,AI 技术为解决传统建模中的计算瓶颈和数据难题提供了全新路径。 对于开发者、数据科学家或公共卫生领域的研究者而言,最关心的是:这套方法能不能在本地跑起来?

weixin_29051811的博客 298

1076B Divisor Subtraction

B. Divisor Subtraction time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given an integer number nn. The following algorith...

memory_qianxiao的博客 1021

从零开始搭建属于自己的语音识别API服务器(ASRT开源项目)

材料准备 云服务器 (本人使用的的是阿里云服务器 Ubuntu(Linux操作系统)) 环境搭建 1. Python 3.7 话不多说直接上代码 sudo su yum -y install git yum -y install gcc yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-deve

zhi_qian的博客 5648

Codefroces 384 D.Taxes(哥德巴赫猜想,三素数定理)

Codefroces 384 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 calcu...

FFOYeah的博客 1016

Qt Quick (QML) 老年人健康管理

通过 **Qt SQL** 模块将所有健康数据(用药记录、体检数据等)安全地存储在本地 **SQLite** 数据库中。你想用 **Qt C++** 结合 **Qt Quick** (QML) 来开发一个老年人健康管理软件,主要功能包含 **用药提醒** 和 **健康记录** (使用 `Qt SQL` 存储数据)。* **UI 框架**: Qt Quick (QML) - 用于构建流畅、动态的用户界面。**数据模型类 (models/MedicationReminder.h / .cpp)**

寒寒豆豆软件公司的博客 193

基于Simulink的单级式光伏并网系统MPPT控制仿真

本文基于Simulink平台,详细介绍了单级式光伏并网系统的MPPT控制仿真实现。主要内容包括:1)阐述MPPT作为光伏系统"智能大脑"的核心作用;2)解析单级式系统架构及扰动观察法(P&O)算法原理;3)以10kW户用系统为例,分步骤演示建模过程,包括光伏阵列搭建、P&O控制器实现(含MATLAB代码)、并网控制设计等;4)通过仿真验证系统在光照突变下的动态响应性能,MPPT效率达98.3%。文章还提出了变步长P&O等优化方向,为光伏系统仿真与控制提供实用指导。

xiaoheshang_123的博客 111

Postgresql流水帐(第四天): DDL 限制约束

CREATE TABLE products ( product_no integer, name text, price numeric CONSTRAINT positive_price CHECK (price > 0) ); CHECK 返回bool 值。 外键参照完整性、引用完整性 A foreign key constraint sp...

weixin_30267697的博客 186

2025年微信小程序获取手机号授权登录注册详细教程(含服务端)。不弹窗原因以及减少组件用量的方法

前端把获取到的code传给后端,后端获取access_token和前端传过来的code,请求服务器接口,即可获取到手机号。

coderYYY的博客 3万+

codeforces736b Taxes (Codeforces Round #382 (Div. 1))

题意:纳税额为金额的最大因数(除了本身)。为了逃税将金额n分为n1+n2+......。问怎样分纳税最少。 哥德巴赫猜想: 任一大于2的偶数都可写成两个质数之和。 质数情况: 任何大于5的奇数都是三个素数之和 因此,如果n是偶数,结果就是2。 如果n是奇数。奇数只能拆成一奇一偶。分为2种情况。一偶是2时,那么如果一奇是质数,结果为2。如果一奇不是质数,那么结果至少为3,...

weixin_30662011的博客 142

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

Codeforces Round #382 (Div. 1) 736B Taxes 【哥德巴赫猜想】

题目传送门:点击打开链接B. Taxestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMr. Funt now lives in a country with a very specific tax laws. The total incom...

Emiya丶的博客 387

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

ACM_cf#382 Div2 D. Taxes(数论水题

Codeforces Round #382 (Div. 2) D. Taxes 题目大意: 给出一个n , n可以表示为 一个或多个不为一的数的和式 , 如果将分解后的数的除数自身外的最大因子相加,问相加结果的最小值。 要求除数自身外的最大因子相加后取min 明显这个数是素数就可了 而我们有 三素数定理:每个充分大的奇数都是三个奇素数之和。 强哥德巴赫猜想:任一大于2的偶数都...

R0oO0o00o0!的博客KqEA7FzwJsLH 241

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

Codeforces Round #382 (Div. 2)解题报告

A.Ostap and Grasshopper 大力模拟题,然而lc233大佬居然tmd怀疑是不是一个环。。。哎想多了 题意都懒得讲了orz B.Urbanization 题意:给你n个数字,让你选n1个数字放到A集合,n2个数字放到B集合,让两个集合各自的平均数  加起来最大 我们强制要求n1 一个数字t放入A堆答案的贡献是t/n1,所以排一遍序后,前n1个数字放入A集合 同理n1

来自Fop_zz的辣鸡题解或教程 754

Codeforces Round #382 (Div. 2) D. Taxes 数论 哥德巴赫猜想

D. Taxes 链接: http://codeforces.com/contest/735/problem/D 题解: 两个定理。三素数定理:大于2的奇数都可以拆成三个素数和的形式 哥德巴赫猜想:任一大于2的偶数都可写成两个质数之和。 然后,判断一下,如果n是奇数,n-2是素数,答案为2。 代码: 1 #include &lt;map&gt; 2 #include...

花海 150

Codeforces Round #382 (Div. 2) D. Taxes(分拆素数和)

题目链接:http://codeforces.com/contest/735/problem/DD. Taxes time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Mr. Funt now lives in a country w

linlinsong—ACM界蒟水! 1031

Codeforces Round #382 (Div. 2) D. Taxes 数论、哥德巴赫猜想

题意:给定一个数n,n可以分成k个数的和(ni >= 2 , sum{ni} == n, k 可以为 1),花费为ni的除本身外的最大因数,求花费和的最小值。 数论、哥德巴赫猜想 任意大于2的偶数可以拆分为两个质数之和 然后2是素数所以ans = 1; 当n 为 奇数时判断是否为素数,如果是素数则 ans = 1; 如果不是,则判断 n - 2是否为素数,如果是则可以把n拆成一个素数和2 ans = 2; 否则只能拆成一个素数+一个大于2的偶数 ans = 3; 复杂度 O(sqrt(n))

Eric的博客 1517

Codeforces Round #382 (Div. 2) -- D. Taxes

Codeforces Round #382 (Div. 2) -- D. Taxes D. Taxes time limit per test  2 seconds memory limit per test  256 megabytes input  standard input output  standard outp

zcc的博客 321

Codeforces Round #382 (Div. 2) D. Taxes (哥德巴赫猜想)

D. Taxes 题目链接 http://codeforces.com/contest/735/problem/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

K键盘里的青春K 617

codeforces Round #382(Div2) D

链接: http://codeforces.com/contest/742/problem/D D. Arpa’s weak amphitheater and Mehrdad’s valuable Hoses time limit per test1 second memory limit per test256 megabytes inputstandard input outputst

你的目光看海的博客 372

Codeforces Round #382 (Div. 2) D. Taxes

D. Taxes time limit per test 2 seconds memory limit per test 256 megabytes Mr. Funt now lives in a country with a very specific tax laws. The total income of mr. Funt during this year i

survivorone的博客 437

Codeforces Round #382 (Div. 2)D. Taxes(哥德巴赫猜想)

题目链接 D. Taxes time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mr. Funt now lives in a country with a ver

fouzhe的博客 423
上一篇: Codeforces Round #382 (Div. 1) A. Tennis Championship
下一篇: hdu1880 魔咒词典 (hash)
overload1997
博客等级 码龄11年 328粉丝 210原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值