Skip 250pt. It's a question.
500pt
Given N (<= 1e18), obtain the largest factor, and this factor is completely square. If this factor is x, x * Y = N is satisfied, continue to the enumerated factor to N ^ (1/3.
Finally, judge whether the remaining is completely square.
1000pt
For an permutation and combination question, a center has K routes, and there is only the center point between the routes. Now we want to build n cities, numbered 1 ~ N, so that there is a city in the center, and there is a city at the end of each road, and the other cities are placed in the middle of each road. First, ensure that one city is built at the center and end.
The total number of scheduling methods. The two scheduling methods are different, indicating that at least one city has a different set of neighbors. Neighbors are directly accessible without passing through any city.
Analysis:
First, it is easy to know that the Central City has K neighbors. The city at the end of the road has only one neighbor, and the other city must have two neighbors.
Therefore, consider the K value score for this question:
When K <= 2 and K <= 1, because the path can be connected as a straight line, it is equivalent to arranging n cities, and the first and last exchanges can only be regarded as one, so the answer is n! /2.
K> = 3, first select the central city, n cases, then select the end City C (n-1, k), then the remaining n-k-1 city, to put each on K paths, and should consider the placement order, so is the n-k-1 to k roads, and arrange. N-1-k to k roads can be understood in this way. Insert a n-1-k stick in a K-1 * | **, in the n-1-k + k-1 = n-2, select the position of the K-1 stick, and finally (n-k-1 )! * C (n-2, k-1), ANS = N * C (n-1, k) * (n-k-1 )! * C (n-2, k-1) = n! * (N-2 )! /(K-1 )! /(N-k-1 )! /K !.
Code:
1 //Template update date: 20140316 2 #include <iostream> 3 #include <sstream> 4 #include <cstdio> 5 #include <climits> 6 #include <ctime> 7 #include <cstring> 8 #include <cstdlib> 9 #include <string> 10 #include <stack> 11 #include <set> 12 #include <map> 13 #include <cmath> 14 #include <vector> 15 #include <queue> 16 #include <algorithm> 17 #define esp 1e-6 18 #define pi acos(-1.0) 19 #define inf 0x0f0f0f0f 20 #define pb push_back 21 #define lson l, m, rt<<1 22 #define rson m+1, r, rt<<1|1 23 #define lowbit(x) (x&(-x)) 24 #define mp(a, b) make_pair((a), (b)) 25 #define in freopen("solve_in.txt", "r", stdin); 26 #define out freopen("solve_out.txt", "w", stdout); 27 28 #define bug puts("********))))))"); 29 #define inout in out 30 31 #define SET(a, v) memset(a, (v), sizeof(a)) 32 #define READ(a, n) {REP(i, n) cin>>(a)[i];} 33 #define REP(i, n) for(int i = 0; i < (n); i++) 34 #define Rep(i, base, n) for(int i = base; i < n; i++) 35 #define REPS(s, i) for(int i = 0; s[i]; i++) 36 #define pf(x) ((x)*(x)) 37 #define Log(a, b) (log((double)b)/log((double)a)) 38 #define Srand() srand((int)time(0)) 39 #define random(number) (rand()%number) 40 #define random_range(a, b) (int)(((double)rand()/RAND_MAX)*(b-a) + a) 41 42 using namespace std; 43 44 typedef long long LL; 45 typedef unsigned long long ULL; 46 typedef vector<int> VI; 47 typedef pair<int,int> PII; 48 typedef vector<PII> VII; 49 typedef vector<PII, int> VIII; 50 typedef VI:: iterator IT; 51 typedef map<string, int> Mps; 52 typedef map<int, int> Mpi; 53 typedef map<int, PII> Mpii; 54 typedef map<PII, int> Mpiii; 55 const int maxn = 1024*1025+100; 56 LL inv[maxn]; 57 const int M = 1000000007; 58 class Byteland{ 59 public: 60 LL powmod(LL a, LL b, LL M) { 61 LL res = 1; 62 while(b) { 63 if(b&1) res = (res*a)%M; 64 a =(a*a)%M; 65 b >>= 1; 66 } 67 return res; 68 } 69 70 void pre() { 71 Rep(i, 1, maxn) { 72 inv[i] = powmod(i, M-2, M); 73 } 74 } 75 LL solve(LL n, LL k) { 76 pre(); 77 LL ans = 1; 78 if(k <= 2) { 79 Rep(i, 1, n+1) { 80 ans = (ans*i)%M; 81 } 82 ans = ans*powmod(2, M-2, M)%M; 83 } else { 84 Rep(i,1, n+1) { 85 if(i <= k+1) 86 ans = (ans*(n-i+1))%M; 87 if(i <= n-2) 88 ans = (ans*i)%M; 89 if(i <= k) 90 ans = (ans*powmod(i, M-2, M))%M; 91 if(i <= k-1) 92 ans = (ans*powmod(i, M-2, M))%M; 93 } 94 } 95 return ans; 96 } 97 int CountDifferentMaps(int n, int k){ 98 return solve(n, k); 99 }100 };View code