여름 N Tianle [기사] 게임 --2019 (네 번째) 잠깐 전기 멀티 학교 여름 캠프

이 잊거나 그것을 만들기, 가자 말을하려고했다 ...

다음의 설명은 다음과 같습니다 :

\ [1,001 【HDU-6614】 【1,003 \\ HDU-6616】 【1,007 \\ HDU-6620】 【1,008 \\ HDU-6621】 【1,010 \\ HDU-6623 [\]

[1001] 생각 HDU-6614 및 최소 스패닝 트리

http://acm.hdu.edu.cn/showproblem.php?pid=6614

우리는 나무를 구축 할 필요가되도록 오른쪽과 최소값, 두 점 "&"값의 오른쪽.

가정하자 비트 (101), 그리고 두 번째 연결 111로 가정이 시점에서 8이 보일 것이고, 그때는 연결을 가리 키지 않는다.

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;

const int maxn = 2e5+5;

int a[maxn];

int wei(int x) {
    int ans = 0;
    while(x) {
        ans ++;
        x /= 2;
    }
    return ans;
}

int main() {
    int t;
    scanf("%d", &t);
    while(t--) {
        int n;
        scanf("%d", &n);
        int x = wei(n);
        int s = 0;
        for(int i = 0; i < x; i++) {
            if((n>>i) & 1) {
                s++;
            }   
        }

        int ans = 0;
        if(s == x) {
            ans ++;
        }
        printf("%d\n", ans);
        for(int i = 2; i <= n; i++) {
            if(ans == 1 && i == n) {    
                printf("1\n");
                break;
            }
            for(int j = 0; j < x; j++) {
                if((i>>j) & 1) {
                    continue;
                }
                printf("%d%c", (1<<j), i==n?'\n':' ');
                break;
            }
        } 
    }
    return 0;
}

[1003] 생각 HDU-6616은 돌을 분할

http://acm.hdu.edu.cn/showproblem.php?pid=6616

주어 가중치 \ (1 \) 받는 \ N- (\) \ N- (\) 돌하면 동일한 중량으로 분할되므로, 개수도 동일 \ (K \) 기는 보장 \ (K \) 된다 (\ N-을 \) 제수. 출력 특정 할당 방식.

참조 : https://www.cnblogs.com/isakovsky/p/11281662.html

첫째, 만약 \ (1 \) 하기 (\ n \) 합 나누지 \ (케이 \)를 , 다음 할당되지 않아야하고, 그렇지 않으면 할 수있을 것이다.

세트 \ (N-m = / K \) . \ (m의 \)의 돌의 각각의 블록에 할당 된 번호이다. 우리는 N 돌 배치 \ (m *에서의 유전율 \) 세 그룹으로 나누어 돌 12을 가정하면, 행렬.
\ [\ 시작 bmatrix {} 1 & 2 및 3 \\ 4 5 6 7 8 \\ 및 \\ 9 10 11 12 \ {단부 bmatrix} \]

  • m은 각각의 헤드 및 꼬리의 각만큼 복용 짝수 \ (m / 2 \) 캔.
  • m이 홀수 인, 이들의 합은 감소 라인 구성 1 바닥에서 위로 증가하도록 구성되고, 나머지의 홀수 행이 증가하도록 구성된다.
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;



int main() {
    int t;
    scanf("%d", &t);
    while(t--) {
        int n, k;
        scanf("%d%d", &n, &k);
        ll sum = 1ll*n*(n+1)/2;
        if(k == 1) {
            printf("yes\n");
            for(int i = 1; i <= n; i++) {
                printf("%d%c", i, i==n?'\n':' ');
            }
        }
        else if(sum % k) {
            printf("no\n");
        }
        else {
            printf("yes\n");
            if((n/k) % 2 == 0) {
                int x = n / k;
                int cnt = 0;
                for(int i = 1; i <= n/2; i++) {
                    printf("%d %d", i, n-i+1);
                    cnt += 2;
                    if(cnt == x) {
                        printf("\n");
                        cnt = 0;
                    }
                    else {
                        printf(" ");
                    }
                }
            }
            else {
                int x = n / k;
                int tot = 1 + 2*k - k/2;
                int temp = 1;
                for(int i = 1; i <= k; i++) {
                    for(int j = 1; j <= x-2; j++) {
                        if(j % 2 == 1) {
                            printf("%d ", n-(j-1)*k-i+1);
                        }
                        else {
                            printf("%d ", n-j*k+1+i-1);
                        }
                    }
                    printf("%d %d\n", temp, tot - temp);
                    tot ++;
                    temp += 2;
                    if(temp > k) {
                        temp = 2;
                    }
                }
            }
        }
    }
    return 0;
}

[1007] HDU-6620을 그냥 오래된 퍼즐을 생각

http://acm.hdu.edu.cn/showproblem.php?pid=6620

그는 원래의 형태 (단계 120 이하)로 복원 할 수 있다면 디지털 퍼즐을 감안할 때, 내가 물었다.

고전적인 문제 화용 변형.

정리 : 동일한 패리티 반전이 다른으로 변형 될 수 있고, 다른 패리티 반전은 서로 전환 될 수 없다.

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;

int a[20];

int main( ) {
    int t;
    scanf("%d", &t);
    int flag, ans;
    while(t--) {
        ans = 0;
        for(int i = 1; i <= 16; i++) {
            scanf("%d", &a[i]);
            if(a[i] == 0) {
                flag = i / 4 + (i % 4 != 0);
            }
            else {
                for(int j = 1; j < i; j++) {
                    if(a[j] == 0) {
                        continue;
                    }
                    if(a[j] > a[i]) {
                        ans++;
                    } 
                }
            }
        }
        printf((4-flag) % 2 == ans % 2 ? "Yes\n" : "No\n");
    }
    return 0;
}

[1008] 회장 나무 HDU-6621 K 번째 가장 가까운 거리

http://acm.hdu.edu.cn/showproblem.php?pid=6621

감안 \ N- (\) 번호 \ (Q \) 질의, 각 쿼리 \ ([L, R] \ ) 내부 \ (| A [I] - P | \)\ (K \) 많은 수의, 그리고 필수 온라인. 상기 (\ n 개의 \의 당량 1E ^ 5 \ \ q 개의 \의 당량 1E ^ 5 \)

게임에 대해 생각하는 것은 나무의 회장을했을 때,이 큰 상수 k는 멀리, 다음 전체에서 t 최적화 된 방법이 없습니다. 이 법은, 라인에 아마도 그것은 호출 할 필요가 무게 회장 트리 보증금을 변경할 수 있다는 것을 발견했다? QAQ

트리 노드 회장 바로 \ (1E ^ 6 \) 값, 이산되지 각 값의 발생 횟수 단독 통계이다. 이분 쿼리 \ ((P-중반, P + 중간) \) 의 카운트 수.

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;

const int maxn = 1e6 + 5;

int n, m, cnt, new_n;
int a[maxn];
int root[maxn];
vector<int> v;
struct node {
    int l, r, sum;
}T[maxn*40];

void init() {
    v.clear();
    cnt = 0;
}

inline void update(int l, int r, int &x, int y, int val) {
    T[++cnt] = T[y];
    T[cnt].sum ++;
    x = cnt;
    if(l == r) {
        return ;
    }
    int mid = (l+r) / 2;
    if(mid >= val) {
        update(l, mid, T[x].l, T[y].l, val);
    }
    else {
        update(mid+1, r, T[x].r, T[y].r, val);
    }
}

inline int query(int L, int R, int l, int r, int x, int y) {
    if(L <= l && r <= R) {
        return T[y].sum - T[x].sum;
    }
    int mid = (l+r) / 2;
    int ans = 0;
    if(L <= mid) {
        ans += query(L, R, l, mid, T[x].l, T[y].l);
    }
    if(R > mid) {
        ans += query(L, R, mid+1, r, T[x].r, T[y].r);
    }
    return ans;
}

int main() {
    int t;
    scanf("%d", &t);
    while(t--) {
        init();
        int MAX = 1000000;
        scanf("%d%d", &n, &m);
        for(int i = 1; i <= n; i++) {
            scanf("%d", &a[i]);
        }
        for(int i = 1; i <= n; i++) {
            update(1, MAX, root[i], root[i-1], a[i]);
        }
        int ans = 0;
        for(int i = 1; i <= m; i++) {
            int l, r, p, k;
            scanf("%d%d%d%d", &l, &r, &p, &k);
            l = l^ans;
            r = r^ans;
            p = p^ans;
            k = k^ans;
            
            int L = 0;
            int R = MAX;
            while(L <= R) {
                int mid = (L+R) >> 1;
                if(query(max(1, p-mid), min(MAX, p+mid), 1, MAX, root[l-1], root[r]) >= k) {
                    ans = mid;
                    R = mid - 1;
                }
                else {
                    L = mid + 1;
                }
            }
            printf("%d\n", ans);
        }
    }
    return 0;
}

프라임의 [1010] 수학 HDU-6623 최소 전원

http://acm.hdu.edu.cn/showproblem.php?pid=6623

숫자 감안할 때 \ (\ N- 형) 인덱스의 가장 큰 수를 수용하기 위해 경향을 추구을.

고려 (N ^ {1/5} \ \ ) 범위의 소수는, 산출 범위 내의 소수의 최소 수는 번호이고,이 소수 나머지 숫자를 수득 한 다음 제거 \ (m의 \) 고려 \ (m의 \) 만약 이상 10,009 (소수가 1 ~ N ^ (1/5)이 소수의 범위, 해당 범위 (10009,1e18)에서는,이 시점에 공지되어 최소의 소수 10009, 가장 많은 전력은 가장 작은 소수 4는 논의 m은 소수 전원 여부, 그렇지 않은 경우 1) 힘, 2,3,4-이다. 특수 1 선고했다.

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;

const int maxn = 1e4+5;

int vis[maxn], pri[maxn];
int tot;
ll n;

void prime() {
    for(int i = 2; i < maxn; i++) {
        if(vis[i] == 0) {
            pri[tot++] = i;
            for(int j = i*i; j < maxn; j+=i) {
                vis[j] = 1;
            }
        }
    }
}

int check(ll x) {
    int l = 0;
    int r = 1000000;
    while(l <= r) {
        int mid = (l+r) >> 1;
        if(1ll*mid*mid*mid == x) {
            return 1;
        }
        if(1ll*mid*mid*mid > x) {
            r = mid-1;
        }
        else{
            l = mid+1;
        }
    }
    return 0;
}

int main() {
    prime();
    int t;
    scanf("%d", &t);
    while(t--) {
        scanf("%lld", &n);
        if(n == 1) {
            printf("0\n");
            continue;
        }
        ll ans = n;
        for(int i = 0; i < tot; i++) {
            if(n == 1) {
                break;
            }
            if(n % pri[i] == 0) {
                int cnt = 0;
                while(n % pri[i] == 0) {
                    cnt ++;
                    n /= pri[i];
                }
                ans = min(ans, 1ll*cnt);
            }
        }
        if(n >= maxn) {
            ll s1 = (ll)sqrt(n);
            ll s2 = (ll)sqrt(s1);
            if(s2*s2*s2*s2 == n) {
                ans = min(ans, 4ll);
            }
            else if(s1*s1 == n) {
                ans = min(ans, 2ll);
            }
            else if(check(n)) {
                ans = min(ans, 3ll);
            }
            else {
                ans = min(ans, 1ll);
            }
        }
        printf("%lld\n", ans);
    }
    return 0;
}

추천

출처www.cnblogs.com/Decray/p/11305275.html