[AGC003D] Anticube

Problem Statement

Snuke got positive integers $s_1,...,s_N$ from his mother, as a birthday present. There may be duplicate elements.

He will circle some of these $N$ integers. Since he dislikes cubic numbers, he wants to ensure that if both $s_i$ and $s_j (i ≠ j)$ are circled, the product $s_is_j$ is not cubic. For example, when $s_1=1,s_2=1,s_3=2,s_4=4$, it is not possible to circle both $s_1$ and $s_2$ at the same time. It is not possible to circle both $s_3$ and $s_4$ at the same time, either.

Find the maximum number of integers that Snuke can circle.

Constraints

  • $1 ≦ N ≦ 10^5$
  • $1 ≦ s_i ≦ 10^{10}$
  • All input values are integers.

首先 Pollard-Pho 分解质因数(bushi

然后考虑把 \(x\) 每一个因数的指数 \(\bmod 3\) 后出来一个数 \(f(x)\)。那么在这个问题中,若 \(f(x)=f(y)\) ,那么 \(x\)\(y\) 本质是相同的,看做一个等价类。

同时可以发现,把所有指数给取反后,出来一个 \(g(x)\),那么 \(g(x)\) 代表的等价类和 \(f(x)\) 中的数不能同时出现。

这样就很好统计了。

然后你真的想用 Pollar-Pho 吗?

对于 \(x\) 的某一个超过 \(\sqrt[3]{n}\) 质因数,他的指数不会超过 \(3\),所以容易算出 \(f(x)\)

在计算 \(g(x)\) 的时候,把所有在 \(\sqrt[3]{n}\) 之内的因数筛完之后,假设出来是 \(d\),那么如果 \(d=x^2\)\(g(x)\) 乘上 \(\sqrt{d}\),否则如果 \(d\le 1000000\)\(g(x)\) 乘上 \(d^2\),否则 \(g(x)\) 一定超过 \(10^{12}\),不用管。

using namespace std;
typedef long long LL;
const int N=1e5+5;
int n,ans;
LL s;
LL read()
{
	LL s=0;
	char ch=getchar();
	while(ch<'0'||ch>'9')
		ch=getchar();
	while(ch>='0'&&ch<='9')
		s=s*10+ch-48,ch=getchar();
	return s;
}
map<LL,LL>to,mp;
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
	{
		s=read();
		LL v=1,g=1;
		for(int j=2;j<=2200;j++)
		{
			if(s%j==0)
			{
				int c=0;
				while(s%j==0)
					s/=j,++c;
				c%=3;
				if(c==1)
					v*=1LL*j*j,g*=j;
				else if(c)
					v*=j,g*=1LL*j*j;
			}
		}
		g*=s;
		mp[g]++;
		int k=sqrt(s);
		if(1LL*k*k==s)
			v*=k,to[g]=v;
		else if(s<=1000000)
			v*=1LL*s*s,to[g]=v;
	}
	for(map<LL,LL>::iterator it=mp.begin();it!=mp.end();it++)
	{
		LL x=(*it).first;
		if(x==1)
			ans++;
		else
			ans+=max(mp[x],to.find(x)!=to.end()&&mp.find(to[x])!=mp.end()? mp[to[x]]:0);
		mp[x]=mp[to[x]]=0;
	}
	printf("%d",ans);
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在Matlab中,AGC(Automatic Gain Control)是一种用于自动调节信号增益的技术AGC系统的作用是保持信号在一个适当的功率范围内,以便有效地处理和分析信号。使用Matlab可以实现数字AGC系统的建模与仿真。 在Matlab中使用Simulink环境进行数字AGC的建模与仿真可以通过以下步骤实现: 1. 使用Simulink库中的信号源模块生成输入信号。可以使用随机信号或特定模式的信号作为输入。 2. 将信号传递到AGC模块,该模块可以从Simulink库中选择或自定义。 3. 配置AGC模块的参数,例如增益平均系数、增加步进、减小步进、参考级别、上限和下限等。 4. 将AGC模块的输出与其他模块连接,例如显示模块或数据处理模块。 5. 运行模型并观察AGC系统的输出结果。 通过以上步骤,您可以使用Matlab中的Simulink环境建立数字AGC模型,并使用Matlab实现数字AGC系统。需要注意的是,在实际应用中,数字AGC系统的复杂程度可能会更高,需要根据具体情况进行调整和优化。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [基于Simulink的数字AGC建模与仿真](https://blog.csdn.net/CodeWG/article/details/130591628)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值