Ujan has been lazy lately, but now has decided to bring his yard to good shape. First, he decided to paint the path from his house to the gate.

The path consists of nn consecutive tiles, numbered from 11 to nn. Ujan will paint each tile in some color. He will consider the path aesthetic if for any two different tiles with numbers ii and jj, such that |j−i||j−i| is a divisor of nn greater than 11, they have the same color. Formally, the colors of two tiles with numbers ii and jj should be the same if |i−j|>1|i−j|>1 and nmod|i−j|=0nmod|i−j|=0 (where xmodyxmody is the remainder when dividing xx by yy).

Ujan wants to brighten up space. What is the maximum number of different colors that Ujan can use, so that the path is aesthetic?

Input

The first line of input contains a single integer nn (1≤n≤10121≤n≤1012), the length of the path.

Output

Output a single integer, the maximum possible number of colors that the path can be painted in.

Examples
input

Copy
4
output

Copy
2
input

Copy
5
output

Copy
5
Note

In the first sample, two colors is the maximum number. Tiles 11 and 33 should have the same color since 4mod|3−1|=04mod|3−1|=0. Also, tiles 22and 44 should have the same color since 4mod|4−2|=04mod|4−2|=0.

In the second sample, all five colors can be used.

#include<bits/stdc++.h>
using namespace std;
int main(){
long long n;cin>>n;
int flag = ;
long long num = n;
for(long long i=;i*i<=n;i++){
if(n%i==){
num=__gcd(num,i);
num=__gcd(num,n/i);
}
}
cout<<num<<endl;
}
//求除1以外所以因子的最大公约数
/*我们枚举n的所有的因子 a[1],a[2],a[3]....a[x]。
翻译过来就是我们每a[1]个,都得相同;每a[2]个都得相同;....;每a[x]个都得相同。
那么实际上这个东西的循环节就等于他们的最小公倍数。
那么最多个颜色就是n/lcm,实际上就是gcd。因为gcd x lcm = n */

Codeforces Round #599 (Div. 2) C. Tile Painting的更多相关文章

  1. Codeforces Round #599 (Div. 1) A. Tile Painting 数论

    C. Tile Painting Ujan has been lazy lately, but now has decided to bring his yard to good shape. Fir ...

  2. Codeforces Round #599 (Div. 2) D. 0-1 MST(bfs+set)

    Codeforces Round #599 (Div. 2) D. 0-1 MST Description Ujan has a lot of useless stuff in his drawers ...

  3. Codeforces Round #599 (Div. 2)

    久违的写篇博客吧 A. Maximum Square 题目链接:https://codeforces.com/contest/1243/problem/A 题意: 给定n个栅栏,对这n个栅栏进行任意排 ...

  4. Codeforces Round #599 (Div. 2) Tile Painting

    题意:就是给你一个n,然后如果  n mod | i - j | == 0  并且 | i - j |>1 的话,那么i 和 j 就是同一种颜色,问你最大有多少种颜色? 思路: 比赛的时候,看到 ...

  5. Codeforces Round #353 (Div. 2) B. Restoring Painting 水题

    B. Restoring Painting 题目连接: http://www.codeforces.com/contest/675/problem/B Description Vasya works ...

  6. Codeforces Round #461 (Div. 2) C. Cave Painting

    C. Cave Painting time limit per test 1 second memory limit per test 256 megabytes Problem Descriptio ...

  7. Codeforces Round #599 (Div. 2)D 边很多的只有0和1的MST

    题:https://codeforces.com/contest/1243/problem/D 分析:找全部可以用边权为0的点连起来的全部块 然后这些块之间相连肯定得通过边权为1的边进行连接 所以答案 ...

  8. Codeforces Round #599 (Div. 2) E. Sum Balance

    这题写起来真的有点麻烦,按照官方题解的写法 先建图,然后求强连通分量,然后判断掉不符合条件的换 最后做dp转移即可 虽然看起来复杂度很高,但是n只有15,所以问题不大 #include <ios ...

  9. Codeforces Round #599 (Div. 1) C. Sum Balance 图论 dp

    C. Sum Balance Ujan has a lot of numbers in his boxes. He likes order and balance, so he decided to ...

随机推荐

  1. substring && substr

    let string = '0123456';string.substring(0,3);//start: number, end?: number 012(而非 0123)string.substr ...

  2. Coxeter积分计算

    \begin{align*}&\int_0^{\frac{\pi}{3}}{\arccos \left( \frac{1-\cos x}{\text{2}\cos x} \right) dx} ...

  3. BK: Data mining, Chapter 2 - getting to know your data

    Why: real-world data are typically noisy, enormous in volume, and may originate from a hodgepodge of ...

  4. windows ltsc版本没有Microsoft Store怎么解决

      [背景]以前一直都是使用windows的企业版,后来发现ltsc版本更好,这个好处在这里就不多说,懂的人自然会懂.但是发现很多应用都没有,包括Microsoft Store商店都没有.下面就是解决 ...

  5. idea修改忽视文件产生得bug

    为了提交代码方便,在idea中增加了忽视文件选项. 这一修改可把自己坑惨了,更改代码运行代码得时候,连打印都没出来,对照了半天代码 也没发现是哪里得错误,后来想到某次修改代码后class文件并没改变, ...

  6. jdk8-》allMatch、anyMatch、max、min函数

    allMatch函数: 检查是否匹配所有元素,只有全部符合才返回true boolean flag = list.stream().allMatch(obj->obj.length()>5 ...

  7. [codeigniter4]Upgrading from 3.x to 4.x

    CodeIgniter 4 is a rewrite of the framework, and is not backwards compatible. It is more appropriate ...

  8. Java中new一个子类对象的同时并不会自动创建一个父类对象

    首先重申一个概念:子类会继承父类所有非私有成员变量和方法,包括父类的构造方法 当创建一个子类对象时,首先开辟内存,然后调用类的构造函数,这里的构造函数由两部分组成,一部分是从父类继承而来的父类的构造方 ...

  9. [HAOI2016] 找相同字符 - 后缀数组,单调栈

    [HAOI2016] 找相同字符 Description 给定两个字符串,求出在两个字符串中各取出一个子串使得这两个子串相同的方案数.两个方案不同当且仅当这两个子串中有一个位置不同. \(n,m \l ...

  10. [luogu3950] 部落冲突 - Link Cut Tree

    有了LCT这不就是思博题了吗 #include <bits/stdc++.h> using namespace std; const int N = 1000000; int n,m,t1 ...