【】 6014 HDU
SOLVED
[Title] effect given N nodes, the distance between two points is the node number and, in this context, minimum spanning tree, and the cost of output path
[Idea] lowbit by seeking a position of 0, and so the value of this bit is 1, the optimal solution is
[Summary] 1. After the split or they have to consider the characteristics of binary
2. When checking algorithm correctness, verification data to verify if their maximum capacity
(Is more experience)
#include<iostream> #include<algorithm> #include<vector> #include<stack> #include<queue> #include<string> #include<cstring> #include<climits> #include<cmath> #include<map> #include<set> #include<deque> using namespace std; const int maxn = 2e5 + 10; int arr[maxn]; int lowbit(int x) { return x & -x; } int main() { ios_base::sync_with_stdio(false); int T; cin >> T; while (T--) { int N; cin >> N; int cal = 0; for (int i = 2; i <= N; i++) { if ((i & 1) == 0) arr[i] = 1; else { int t =lowbit((i + lowbit(i))); if (t <= N) arr[i] = t; else { arr[i] = 1; cal++; } } } cout << cal << "\n"; for (int i = 2; i <= N; i++) { cout << arr[i]; if (i != N) cout << ' '; } cout << "\n"; } }
【】 6015 HDU
UNSOLVED
【】 6016 HDU
UNSOLVED
【】 6017 HDU
UNSOLVED
【】 6018 HDU
UNSOLVED
【】 6019 HDU
UNSOLVED
【】 6020 HDU
SOLVED
[Title] to effect a puzzle number of 4 * 4, can return to a predetermined shape
[Thinking] digital puzzle conclusions
#include<iostream> #include<algorithm> #include<vector> #include<stack> #include<queue> #include<string> #include<cstring> #include<climits> #include<cmath> #include<map> #include<set> #include<deque> #include<unordered_map> using namespace std; struct node { int arr[5][5]; bool operator<(const node& a)const { for (int i = 1; i <= 4; i++) { for (int j = 1; j <= 4; j++) { if (arr[i][j] >= a.arr[i][j]) return false; } } return true; } node() {}; node(const int a[][5]) { for (int i = 1; i <= 5; i++) { for (int j = 1; j <= 5; j++) { arr[i][j] = a[i][j]; } } } }; map<node, int>mp; int arr[16]; const int mx[4] = { 0,-1,0,1 }; const int my[4] = { 1,0,-1,0 }; int main() { ios_base::sync_with_stdio(false); int T; cin >> T; while (T--) { int cal = 0; int px; for (int i = 1; i <= 16; i++) { int n; cin >> n; if (n == 0) { px = (i - 1) / 4 + 1; continue; } arr[++cal] = n; } int cnt = 0; for (int i = 1; i <= 15; i++) { for (int j = i + 1; j <= 15; j++) { if (arr[i] > arr[j]) cnt++; } } if ((cnt + 4 - px) % 2 == 0) cout << "Yes\n"; else cout << "No\n"; } }
【】 6021 HDU
UNSOLVED
【】 6022 HDU
UNSOLVED
【】 6023 HDU
SOLVED
[Title] effect
[Idea] of prime special treatment, first find N ^ 1/5, then the remaining power of a prime number is limited to a maximum of 4, the root can quickly solve two separate
#include<cstdio> #include<iostream> #include<algorithm> #define ll long long using namespace std; ll pri[10001]; int vis[10001]; int cntp; void init() { for (ll i = 2; i < 10000; i++) { if (!vis[i]) { cntp++; pri[cntp] = i; } for (int j = 1; j <= cntp&&pri[j]*i<10000; j++) { vis[i*pri[j]] = 1; if (i%pri[j] == 0) { break; } } } } ll sqrt(ll num,int d) { ll l = 1, r = num; while (l <= r) { ll mid = (l+r) / 2; ll tmp = LLONG_MAX; if(d==3) { tmp = tmp / mid; } if (d == 4) { tmp = tmp / mid; tmp /= mid; } if (tmp / mid < mid) { r = mid - 1; continue; } tmp = 1; for (int i = 1; i <= d; i++) tmp *= mid; if (tmp == num) return mid; if (tmp > num) r = mid - 1; else l = mid + 1; } return 0; } int main() { init(); int T; scanf("%d", &T); while (T--) { ll n; scanf("%lld", &n); int ans = INT_MAX; for (int i = 1; i <= cntp; i++) { if (pri[i] > n) break; int cnt = 0; while (n%pri[i] == 0) { cnt++; n/= pri[i]; } //if (cnt) // printf("cnt %d pri %lld\n", cnt, pri[i]); if (cnt < ans &&cnt) ans = cnt; } Int no = INT_MAX; if (n> 1 ) { if (sqrt (n, 4 )) nothing = min (res, 4 ); else { if (sqrt (n 2 )) nothing = min (all, 2 ); } If (sqrt (n, 3 )) nothing = min (res, 3 ); f (res == INT_MAX && n > 4500) res = 1; } printf("%d\n", min(ans,res)); } //printf("1000000000000000000 %lld %lld\n", sqrt(1000000000000000000, 3), sqrt(1000000000000000000, 2)); return 0; }