1263-C Everyone is a Winner! (整除分块)

[Codeforces]1263C Everyone is a Winner! 题目 On the well-known testing system MathForces, a draw of nnn rating units is arranged. The rating will be distributed according to the following algorithm: if kkk participants take part in this event... 阅读详情

题目

老实说一开始并不知道这题是整除分块,就打表找规律做出来的。想着当一个数15 先除以15/1 = 15 15 /2=7 15/3=5 15/4=3 15/5=3 15/6=2 15/7=2 15/8=2…可以知道除到前面一定只有一个值,到了后面出现出现重复的后从3开始2 1 都会存在且重复。所以把从重复的数比其小的取完,再把前面分散的大的也取完就可以,因为有剪枝不会T掉。

最开始的代码:

#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<stack>;
#include<memory.h>
#include<cmath>
#define FAST ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
const int Max = 1e6 + 5;
int lst[Max];
int b[111];
int main()
{
	int t;cin >> t;
	while (t--)
	{
		stack<int> sta;
		memset(lst, 0, sizeof(lst));
		lst[0] = 0;
		int n;cin >> n;
		int sum = 1, k=0, f=0;
		for (int i = 1;i <= n;i++)
		{
			sta.push(n / i);//k = i;f = n / i;
			if (n / i == n / (i + 1))
			{
				k = i;f = n / i;
				sta.pop();
				break;
			}
		}
		sum = k + f;
		for (int i = 0;i <= f;i++)lst[i] = i;
		while (sta.size() >= 1)
		{
			lst[++f] = sta.top();
			sta.pop();
		}
		if (n == 1)
		{
			cout << 2<<endl << "0 1" << endl;
		}
		else if (n == 2)cout <<3<<endl <<"0 1 2" << endl;
		else
		{
			cout << sum << endl;
			for (int i = 0;i <= f;i++)
			{
				cout << lst[i] << " ";
			}
			cout << endl;
		}
	}
}

整除分块

在这里插入图片描述Code

#include<iostream>
using namespace std;
typedef long long ll;
const int Max = 1e6 + 5;
int lst[Max];
int main()
{
	int t;cin >> t;
	while (t--)
	{
		int n;cin >> n;int d = 0;
		for (int l = 1, r;l <= n;l = r + 1)
		{
			int k = n / l;lst[++d] = k;
			r = n / k;
		}
		lst[++d] = 0;cout << d << endl;
		for (int i = d;i >= 1;i--)cout << lst[i] << " ";
		cout << endl;
	}
}

PSINS工具箱15状态组合导航仿真程序(test_SINS_GPS_153)浅析-卡尔曼滤波设置+导航解算 文章目录test_SINS_GPS_153源码poserrsetkfinitgabiaskfupdate流程 test_SINS_GPS_153源码 poserrset function poserr = poserrset(dpos0, dlon, dhgt) % position errors dpos=[dlat;dlon;dhgt] setting. % % Prototype: poserr = poserrset(dpos0) % Input: dpos0=[dlat; dlon; dhgt], 阅读详情

相关推荐

从零搭建PIC MCU开发环境:MPLAB IDE与HI-TECH编译器安装破解全攻略

本文详细介绍了从零搭建PIC MCU开发环境的完整流程,包括MPLAB IDE 8.85的安装配置、HI-TECH C编译器的安装与破解,以及PICkit3编程器的使用技巧。通过清晰的步骤说明和常见问题解决方案,帮助开发者快速搭建稳定的PIC单片机开发环境,适用于PIC16/18系列MCU开发。

weixin_29188997的博客 298

C. Everyone is a Winner!

输入一个数n,求出n/k(k 任意)向下取整有几种数,输出这几种数 int n,m,t; int i,j,k; set<int> s; int main() { //IOS; rush(){ sd(n); s.clear(); s.insert(0); for(int i=1;i*i<=n;i++){ s.insert(i); s.insert(n/i); ...

C_Dreamy的博客 514

05-SA8155 QNX Display框架及代码分析(1)

显示是非常重要的一个模块,人机交互的桥梁。那么SA8155 Hypervisor显示是如何处理的呢。对处理流程非常的好奇O(∩_∩)O哈哈~。TODO。

静虚待令,有物混成 1万+

CF寒假补题——Everyone is a Winner

On the well-known testing system MathForces, a draw ofnnrating units is arranged. The rating will be distributed according to the following algorithm: ifkkparticipants take part in this event, then thennrating is evenly distributed between them an...

m0_54674275的博客 273

setoolkit克隆网站获取用户信息

一、环境 kali、DVWA 二、步骤 首先打开kali,输入setoolkit 依次选择选项1-选项2-选项3-选项2 输入钓鱼网站的网址(默认为本地网址) 输入要克隆的网址URL 这里我的网址如图,将网址复制 然后模拟攻击场景,攻击者向受害者发送了一条钓鱼链接,此链接与DVWA的登陆页面完全一样,受害者点击之后并进行登陆信息 点击login之后,用户信息就被setool...

BeatRex的博客 3001

OPC与AI智能体集成实战:一人公司的技术栈构建与避坑指南

1. 先搞清楚“一人公司”和“AI工具”到底在解决什么问题 最近看到不少关于“裸辞搞OPC一人公司”和“AI时代骗局”的讨论,结合搜索热词里高频出现的 openclaw 、 AI编程 、 OPC ,我觉得有必要把这里面的水搅一搅,说点实在的。 首先得拆开看。标题里混了三个东西: 一人公司 、 OPC/OpenClaw 、 AI培训 。它们被放在一起讨论“骗局”,但本质上解决的是不同层面的问题。 一人公司 ,或者说个人工作室、独立开发者模式,核心是 用最小化团队(甚至一个人)去承接项目、开发产品或提供服务 。

weixin_29038345的博客 323

Codeforces 1263C. Everyone is a Winner!(整除分块)

传送门 题意: 输入一个数n,求出n/i(i取任意)向下取整有几种数,并输出 思路: 整除分块裸题 for(int l=1,r;l<=n;l=r+1) { r=n/(n/l); a[++cnt]=n/l; } cnt代表分块的块的个数,每个块里的值为a[i]=n/l,l为块的左端点,r为块的右端点r=n/(n/l) 代码: #include <iostream> #i...

_Alexander的博客 310

Verilog流水线CPU设计(超详细)

快把这一篇给更了

Ace Cheney的博客 7万+

【CodeForces 1263C --- Everyone is a Winner!】

【CodeForces 1263C --- Everyone is a Winner!】 Description On the well-known testing system MathForces, a draw of n rating units is arranged. The rating will be distributed according to the following al...

来日浅谈的博客 1107

《Autosar_MCAL高阶配置》总目录_培训教程持续更新中...

《Autosar_MCAL高阶配置》总目录_培训教程持续更新中...

「汽车电子助手」的博客 1万+

10款AI工具赋能虚拟展厅设计:架构师效率提升90%的秘密武器

2020年全球疫情成为数字转型的催化剂,虚拟展厅从"可选项"迅速转变为"必需品"。根据Gartner最新报告,到2025年,超过70%的企业将采用虚拟展厅作为客户体验和产品展示的核心渠道。这一转变不仅是应急措施,更是商业模式的永久性革新。虚拟展厅突破了物理空间的限制——一个精心设计的虚拟展厅可以同时接待来自全球各地的访客,无需考虑场地容量;展品可以以数字形式永久保存,避免了物流和损耗问题;数据分析功能可以精确追踪每位访客的行为轨迹,提供前所未有的洞察。数据透视。

AI 领航者的博客 1583

Everyone is a Winner! CodeForces - 1263C(二分 除法分块)

On the well-known testing system MathForces, a draw of n rating units is arranged. The rating will be distributed according to the following algorithm: if k participants take part in this event, then ...

tomjobs的博客 616

CodeX 登录报错 os error 10013?一键修复 CodeX 无法登录问题(亲测有效)

CodeX 登录时报 os error 10013?本文提供快速修复方案,实测有效,彻底解决登录报错:登录失败:failed to start login server: 以一种访问权限不允许的方式做了一个访问套接字的尝试。 (os error 10013)的问题💡

XiaoqiangClub的博客 2962

Everyone is a Winner! CodeForces - 1263C

一、 内容 On the well-known testing system MathForces, a draw of n rating units is arranged. The rating will be distributed according to the following algorithm: if k participants take part in this event,...

Tizzi的博客 750

lwip-2.0.3

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

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

Codeforces 1263C Everyone is a Winner(枚举or数论分块)

Description \quadOn the well-known testing system MathForces, a draw of n rating units is arranged. The rating will be distributed according to the following algorithm: if kkk participants take part i...

邵光亮的博客 681

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

Codeforces 1263C Everyone is a Winner!

思路: 1.首先根据素数判定的经验,我们需要将nnn取根号再进行遍历; 2.[n/a]=b[n/a]=b[n/a]=b则有[n/b]=a[n/b]=a[n/b]=a;取了根号我们只需要计算小于等于nnn的值,然后将除的结果作为另一个值就ok了~ 代码: #include<bits/stdc++.h> using namespace std; int main(){ ios::sy...

Yuhan的博客 259

codeforces C. Everyone is a Winner!

原题链接:codeforces C. Everyone is a Winner! 题目要求 On the well-known testing system MathForces, a draw of nn rating units is arranged. The rating will be distributed according to the following algorithm: ...

atnanajiang的博客 676

Codeforces Round #603 (Div. 2)C. Everyone is a Winner!(1263C)题解

C. Everyone is a Winner! On the well-known testing system MathForces, a draw of n rating units is arranged. The rating will be distributed according to the following algorithm: if k participants take ...

sg2021的博客 481

Everyone is a Winner! CodeForces - 1263C(思维水)

On the well-known testing system MathForces, a draw of n rating units is arranged. The rating will be distributed according to the following algorithm: if k participants take part in this event, then ...

starlet_kiss的博客 205

codeforces div2 603 C. Everyone is a Winner!(二分)

题目链接:https://codeforces.com/contest/1263/problem/C 题意:给你一个数字n,求n/k有多少个不同的数 思路:首先K大于n时,n/k是0。然后k取值在1到n之间的时候进行二分即可求解。 举个例子,比如n = 11,那么k分别取值1 2 3 4 5 6 7 8 9 10 11时候,n/k是 11 5 3 2 2 1 1 1 1 ...

qq_41949535的博客 263

C. Everyone is a Winner!(优化数据,二分)

C. Everyone is a Winner!(优化数据,二分)

qq_63052532的博客 121

[Codeforces] #603 (Div. 2) A-E题解

[Codeforces]1263A Sweet Problem [Codeforces]1263B PIN Code [Codeforces]1263C Everyone is a Winner! [Codeforces]1263D Secret Passwords [Codeforces]1263E Editor

The Clouder's 242

二叉排序树的构造及其基本操作

二叉排序树的定义 对于一棵空的二叉树或者具有如下性质的二叉树: 1.若其左子树不为空,则左子树所有结点的值均小于根结点的值。 2.若其右子树不为空,则右子树所有结点的值均大于根结点的值。 3.其左右子树也是二叉排序树。 如: 相关图片来源《数据结构——从概念到C++实现(第三版)》 二叉排序树中对值的查找 给定一个值p,当前结点为bt,若bt->data==p,查找成功。 若pdata,则在pt左子树查找。 若p>bt->data,则在pt右子树查找。 BiNode* BiSortTree

Rikkaの博客 3万+

排序算法的实现及性能测试及比较

在书中,各种内部排序算法的时间复杂度分析结果只给出了算法执行时间的阶,或大概执行时间。试通过具体数据比较各种算法的关键字比较次数和记录移动次数,以取得直观感受。 要求: (1)编写程序创建一些整数文件用于排序。创建的这些文件可以根据需要生成不同的长度,如长度分别为20,200和2000,以正序、逆序、随机顺序的方式创建这些文件,通过把所有这些测试数据保存在文件中(而不是每次在测试程序时用随机数生成),可以使用同样的数据去测试不同的方法,因此会更易于比较这些方法的性能。 (2)数据表采用顺序存储结构,实现插入

Rikkaの博客 4928

信息检索系统——VSM算法实现

匹配文档样例 查询样例 匹配结果样例 python–源码如下 import math from tqdm import tqdm df_dict={} global docs_num #一个全局变量,保留全部文档数 docs_num=0 def doc_pl(doc): #求出文档中的词频数,及总词数,用于tf-idf的计算 word_list=doc.split() num=0 word_pl={} for word in word_list[1:

Rikkaの博客 4710
上一篇: 1303 C Perfect Keyboard (DFS)
下一篇: 1263 - D. Secret Passwords (并查集)
_Rikka_
_Rikka_ 新星创作者: Java技术领域 新星创作者: Java技术领域
博客等级 码龄7年 6310粉丝 194原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

_Rikka_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值