2019.10.03 solving report

Overall play violence are playing
a desired \ (100 + 40 + 30 = 170 \)
Actual \ (100 + 40 + 10 = 180 \)
data conscience (In fact, the data is too much water mess

T1

The first thing is to find that the laws, then look straight out, so use search about violence

#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream> 
using namespace std;

const int N = 2011;

int vis[N][N];

struct node {
    int x, y, num;
};

const int dx[8] = {-2,-2,-1,1,2,2,1,-1};
const int dy[8] = {-1,1,2,2,1,-1,-2,-2};

queue <node> q;

int sum = 0;

int main() {
    for(int T = 0; T <= 100; T++) {
        int n = T;
        sum = 0;
        memset(vis, 0, sizeof(vis));
        while(!q.empty()) q.pop();
        node st;
        st.x = 1000;
        st.y = 1000;
        vis[st.x][st.y] = 1;
        st.num = 0;
        q.push(st);
        while(!q.empty()) {
            node top = q.front();
            q.pop();
            sum++;
            for(int i = 0; i < 8; i++) {
                node tmp;
                tmp.x = top.x + dx[i]; 
                tmp.y = top.y + dy[i];
                tmp.num = top.num + 1;
                if(!vis[tmp.x][tmp.y] && tmp.x >= 0 && tmp.y >= 0 && tmp.x <= 2000 && tmp.y <= 2000 &&tmp.num <= n) {
                    vis[tmp.x][tmp.y] = tmp.num;
                    q.push(tmp);
                }
            }
        }
        cout  << sum << '\n';
    }
}

What law can not be found, so ask about the difference, or no law, then ask what the difference with a difference, find the difference between the first five is special, so special output directly, others find the difference between constant \ ( 28 \) , the law would find it

\(if(n > 5)\ n \ \ -= 4\)

\ (a \) Number组display original sequence
\ (a [1] = 325 \)
\ (a [2] = 473 \)
\ (a [3] = 649 \)
\ (a [4] = 853 \)
\ (a [5] = 1085 \ )

\ (B \) array represents the difference
\ (B [. 1] = 148 \)
\ (B [2] = 176 \)
\ (B [. 3] = 204 \)
\ (B [. 4] = 232 \)
\ ( ................. \)
\ (B [n-] = 120 + n-28 * \)

Obviously
\ (B [2] = B [. 1] + 28 \)
\ (B [. 3] = B [2] + 28 \)
\ (................. ................... \)
\ (B [n-] = B [n--. 1] + 28 \)


\(a[2] - a[1] = b[1]\)
\(a[3] - a[2] = b[2]\)
\(a[4] - a[3] = b[3]\)
\(a[5] - a[4] = b[4]\)
\(.............................\)
\(a[n] - a[n - 1] = b[n - 1]\)

Pressure caused come
\ (a [2] - a [1] + a [3] - a [2] + a [4] - a [3] + .......... a [n] - a [n - 1] = b [ 1] + b [2] + b [3] + ......... b [n - 1] \)

Remove the excess items, to give
\ (a [n] - a
[1] = \ sum_ {i = 1} ^ {n - 1} b [i] \) is provided \ (x = \ sum_ {i = 1} ^ { n - 1} b [i] \)

So \ (A [n-] X = A + [. 1] \)
X is an arithmetic sequence, then the column sum arithmetic formula \ (\ + FRAC first item of end {} {2} * Number \)

This is \ (\ frac {b [1 ] + b [n - 1]} {2} * (n - 1) \)

It is \ (\ frac {b [1 ] + b [n - 1]} {2} * (n - 1) + a [1] \)

It is equal to \ (\ frac {120 + 28 + 120 + 28 * (n - 1)} {2} * (n - 1) + 325 \)

Then simplify it, might explode \ (Long \ Long \) , safe use \ (unsigned \ Long \ Long \) , and then finished it

//知识点:宽搜打表找规律 
/*
By:Loceaner
找到神奇规律之后发现是等差数列…… 
*/
#include <cstdio>
#include <cstring>
#include <iostream>
#define ull unsigned long long
using namespace std;

int T;
ull n;
ull a[5] = {1, 9, 41, 109, 205};

int main() {
    freopen("horse.in", "r", stdin);
    freopen("horse.out", "w", stdout); 
    scanf("%d", &T);
    while(T--) {
        cin >> n;
        if(n < 5) {
            cout << a[n] << "\n";
            continue;
        }
        else {
            n -= 4;
            ull ans = 120 * (n - 1) + 14 * n * (n - 1) + 325;
//          ull ans = (240 + 28 * n) / 2 * (n - 1) + 325;
            cout << ans << '\n';
        }
    }
    return 0;
}

T2

Obviously, the first question the answer is \ (the n-2 ^ \) .
The second question, then. . Now it will not
then get together dsr told me six months, I would not, on Juju code

#include <bits/stdc++.h>
using namespace std;
const int _=1e5+7;
int n,len,k,vis[_],ans[_];
int main() {
    freopen("sensor.in","r",stdin);
    freopen("sensor.out","w",stdout);
    cin>>k;n=1<<k;
    vis[0]=1;
    for(int i=n-k+1;i<=n;++i) ans[i]=1;
    for(int i=0;i<k;++i) vis[n-(1<<i)]=1;
    for(int i=k+1,jt=0;i<=n-k;++i) {
        jt=(jt<<1)&(n-1);
        if(vis[jt]) ans[i]=1,jt|=1;
        vis[jt]=1;
    }
    printf("%d ",n);
    for(int i=1;i<=n;++i) printf("%d",ans[i]);
    return 0;
}

T3

At first glance think it is tree line, because if a very good operation, but there are fifteen, fifteen open segment tree? ?

Ignorant of the force

Coupled with no time to write, so write a decisive violence, took 40

The following is a violence and 40 points out the code modified

//暴力啦啦啦
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

inline int read() {
    char c = getchar();
    int x = 0, f = 1;
    for( ; !isdigit(c); c = getchar()) if(c == '-') f = -1;
    for( ; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
    return x * f;
}

int r, c, q;
char a[50011][20];
char b[50011][20];

int main() {
    freopen("holiday.in", "r", stdin);
    freopen("holiday.out", "w", stdout);
    r = read(), c = read(), q = read();
    for(int i = 1; i <= r; i++) {
        scanf("%s",a[i]+1);
    }
    for(int i = 1; i <= r; i++) {
        for(int j = 1; j <= c; j++) {
            b[i][j] = '0';
        }
    }
    while(q--) {
        int cnt = 0;
        int u1 = read(), v1 = read(), u2 = read(), v2 = read();
        char col;
        cin >> col;
        for(int i = u1; i <= v1; i++) {
            for(int j = u2; j <= v2; j++) {
                b[i][j] = col;
            }
        }
        for(int i = 1; i <= r; i++) {
            for(int j = 1; j <= c; j++) {
                if(a[i][j] == b[i][j]) cnt++;
            }
        }
        cout << cnt << '\n';
    }
    return 0;
}

Modified

Guess you like

Origin www.cnblogs.com/loceaner/p/11620647.html