【codeforces 19/11/06 div2】C. Tile Painting

 1 #include <iostream>
 2 using namespace std;
 3  
 4 typedef long long LL;
 5  
 6 LL gcd(LL a, LL b)
 7 {
 8     if (!b) return a;
 9     return gcd(b, a % b);
10 }
11  
12 int min(int a, int b)
13 {
14     return a < b ? a : b;
15 }
16  
17 int main() 
18 {
19     LL x;
20     cin >> x;
21     LL div = x;
22     LL i = 2;
23     while (i * i <= x)
24     {
25         if (x % i == 0) div = gcd(div, gcd(i, x / i));
26         if (i & 1) i++;
27         i++;
28     }
29     cout << min(div, x) << endl;
30 }
View Code

猜你喜欢

转载自www.cnblogs.com/thjkhdf12/p/11823798.html