CF 588B Duff in Love

本文介绍了一个算法问题,即从给定正整数n的所有正除数中找出最大的可爱数。可爱数是指不能被任何大于1的整数的平方整除的数。通过去除n中所有可能的平方因子来实现这一目标。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

B. Duff in Love
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Duff is in love with lovely numbers! A positive integer x is called lovely if and only if there is no such positive integer a > 1 such that a2 is a divisor of x.

Malek has a number store! In his store, he has only divisors of positive integer n (and he has all of them). As a birthday present, Malek wants to give her a lovely number from his store. He wants this number to be as big as possible.

Malek always had issues in math, so he asked for your help. Please tell him what is the biggest lovely number in his store.

Input

The first and only line of input contains one integer, n (1 ≤ n ≤ 1012).

Output

Print the answer in one line.

Sample test(s)
input
10
output
10
input
12
output
6
Note

In first sample case, there are numbers 1, 2, 5 and 10 in the shop. 10 isn't divisible by any perfect square, so 10 is lovely.

In second sample case, there are numbers 1, 2, 3, 4, 6 and 12 in the shop. 12 is divisible by 4 = 22, so 12 is not lovely, while 6 is indeedlovely.

对代码解释一下:如果一个数能被i的平方整除,那么就把这个数除I,
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	long long n;
	scanf("%I64d",&n);
	//cin >> n;
	for(long long i=2;i*i<=n;i++)
	{
		while(n%(i*i)==0)n/=i;
	}
	printf("%I64d\n",n);
	//cout<<n<<endl;
	return 0;
}


Porter-Duff算法是图像处理中用于颜色混合的一种技术,它由David Porter和Larry Duff在1984年提出。该算法主要用于计算两个像素的颜色应该如何混合以得到最终结果。在计算机图形学中,它常用于实现诸如透明度、遮罩、绘图等操作。 具体来说,Porter-Duff算法有几种不同的模式: 1. **源(Source)**:新像素完全覆盖旧像素,不考虑旧像素的颜色。 ```python new_color = old_color + src_color ``` 2. **目的地(Destination)**:新像素完全替换旧像素,不管src_color是什么。 ```python new_color = old_color ``` 3. **源过(Over)**:如果新像素比旧像素亮,则显示新像素;反之则保留旧像素。 ```python if src_alpha < old_alpha: new_color = old_color else: new_color = old_color * (1 - src_alpha) + src_color * src_alpha ``` 4. **源在下(In)**:只有当新像素完全位于旧像素内时才显示新像素。 ```python new_color = old_color * (1-src_alpha) + src_color * src_alpha * old_color / src_color ``` 5. **源在上面(Out)**:与"In"相反,只有新像素完全超出旧像素时显示新像素。 ```python new_color = src_color * (1-old_alpha) ``` 6. **清除(Clear)**:设置新像素为全透明(黑色)。 ```python new_color = (0, 0, 0, 0) ``` 这些模式可以通过调整alpha通道(透明度)来控制颜色混合的效果。在Python的图像处理库如PIL或OpenCV中,可以找到对Porter-Duff模式的支持。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值