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;
	}
}

简易电梯控制系统设计(两层楼)( (电子科技大学 数字系统实验二 结课验收项目 ) 题目要求: 阅读详情

相关推荐

PLS-PM with R 偏最小二乘路径建模 (R语言)

1. 引入 1.1. 安装plspm包 plspm 是一个用于执行偏最小二乘路径建模分析的 r 程序包。 在 CRAN 上可以免费下载: Http://cran.r-project.org/web/packages/plspm/index.html. 此后,通过以下代码在r中安装并加载该程序包即可。 install.packages("plspm") library("plspm") 2. 一些简单概念 2.1. 潜变量和观测变量 不少变量如满意度、成功指数是无法通过观测得到

Wowlittlemoon的博客 1万+

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

CISP-PTE考前实操练习题

CISP-PTE考前学习练习题目,渗透测试功工程师

2301_79546223的博客 1998

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

VCL for PHP,Konopka Signature VCL Controls (Raize Components 6.2.3) for Delphi 10.4

The Raize Components suite includes a variety of interface design tools for Delphi programming language and C ++ Builder, which includes over 125 VCL controls and over 100 different tools for creating...

weixin_42137539的博客 853

高频网络协议与编程IO相关面试基本问题和知识点整理

网络IO相关基本高频面试基本问题和知识点整合

曾经“等你生日那天”都遥远得像未来,如今却可欢愉的挥手说“下个十年见” 173万+

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

手把手教你学PCIE(11.3)--pcie的认证和合规性测试

PCIe 设备的认证和合规性测试是确保设备正常工作和达到预期性能的关键步骤。通过使用 PCI-SIG 提供的测试工具和第三方测试工具,可以全面评估 PCIe 设备的物理层、链路层、事务层和互操作性,确保设备符合行业标准和规范。

MHD0815的博客 1360

【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

ximalaya 新xm-sign逆向思路

本文主要介绍目标网站新xm-sign值的逆向思路。仅代表个人理解,如有其他建议可在评论区沟通。声明仅仅记录一下自己的学习方法,不作为其他参考、更不作为商业用途。如有侵犯请联系本人删除。

weixin_66580433的博客 2017

CATIA二次开发核心技术:多实体零件自动化拆解与装配生成深度解析(零件转产品)

CATIA二次开发核心技术:多实体零件自动化拆解与装配生成深度解析

KE17RS的博客 2145

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的博客 615

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

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的博客 748

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

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

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

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

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

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 241

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

二叉排序树的定义 对于一棵空的二叉树或者具有如下性质的二叉树: 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の博客 4925

信息检索系统——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の博客 4709
上一篇: 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、付费专栏及课程。

余额充值