2015 NOIP详解

本文详细解析了2015年全国信息学奥林匹克竞赛(NOIP)的部分题目,包括金币问题的简单模拟,扫雷游戏的模拟与优化,求和问题的高效解决方案,以及涉及贪心策略的推销员问题。每个题目均提供了思路分析,其中求和问题通过分组求解,复杂度控制在O(nlog(n)),而推销员问题展示了较复杂的贪心算法应用。
摘要由CSDN通过智能技术生成

第一题 金币
题目戳这—> https://www.luogu.com.cn/problem/P2669
思路:简单的模拟

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<cmath>
using namespace std;
int main()
{
   
	int n,t=0,sum=0;//t:天数
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
   
		if(t+i<=n)
		{
   
			t+=i;
			sum+=i*i;
			continue;
		}
		sum+=(n-t)*i;
		break;
	}
	printf("%d",sum);
	return 0;
}

第二题 扫雷游戏
题目戳这—> https://www.luogu.com.cn/problem/P2670
思路:简单的模拟+1

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<cmath>
using namespace std;
int main()
{
   
	int n,m;
	scanf("%d%d",&n,&m);
	char c[n+2][m+2];
	int a[n+2][m+2];
	for(int i=0;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值