1. 程式人生 > >10.26 模擬賽

10.26 模擬賽

color col eof stdout src 並不是 wid length ==

技術分享

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>

using namespace std;
const int N = 3e5 + 10;

string s;
char c[N];
int f[N][3];

int main()
{
    freopen("reverse.in","r",stdin);
    freopen(
"reverse.out","w",stdout); cin >> s; int l = 1; int len = s.length(); for(int i = 0; i < len; i ++) c[i + 1] = s[i]; while(c[l] == 0) l ++; int r = len; while(c[r] == 1) r --; for(int i = 1; i <= len; i ++) if(c[i] == 0) f[i][1
] = f[i - 1][1], f[i][0] = f[i - 1][0] + 1; else f[i][0] = f[i - 1][0],f[i][1] = f[i - 1][1] + 1; int answer = 10000009; int n = len; for(int i = 1; i <= n + 1; i ++) answer = min(answer, f[n][0] - f[i - 1][0] + f[i - 1][1]); printf("%d", answer == 10000009 ? 0 : answer);
return 0; } /* 010001 0001000001110111111 11111111111111011111111111011111111111 1010100001 */

技術分享

#include<iostream>
#include<cstdio>
#include<cstring>

#define size 1024

using namespace std;
int n,cnt[size],vis[10];
int Use[10]={1,2,4,8,16,32,64,128,256,512};
long long ans;

int main()
{
    freopen("number.in","r",stdin);
    freopen("number.out","w",stdout);
    cin>>n;
    int start,End;
    for(int i=1;i<=n;i++)
    {
        start=i;End=0;memset(vis,0,sizeof vis);
        while(start) vis[start%10]=1,start/=10;
        for(int j=0;j<=9;j++) if(vis[j]) End+=Use[j];
        cnt[End]++;
    }
    for(int i=0;i<size;i++) ans+=1ll*cnt[i]*(cnt[i]-1)/2;
    cout<<ans<<endl;
    fclose(stdin);fclose(stdout);
    return 0;
}

技術分享

#include <bits/stdc++.h>
using namespace std;

const int maxn = 2000008;
int n, m, a[maxn]; 

int getInt() {
    int res = 0; char c;
    do c = getchar();
    while (!isdigit(c));

    while (isdigit(c))
        res = (res << 1) + (res << 3) + c - 0, c = getchar();

    return res;
}

int main() {
    freopen("wave.in", "r", stdin);
    freopen("wave.out", "w", stdout);

    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++)
        scanf("%d", a + i);
    int ans = 1, k = 0, cur = a[0];
    for (int i = 1; i < n; i++)
        if (k) 
            if (cur - m >= a[i])
                k = 0, cur = a[i], ans++;
            else cur = max(cur, a[i]);
        else 
            if (a[i] - m >= cur)
                k = 1, cur = a[i], ans++;
            else cur = min(cur, a[i]);
    printf("%d\n", ans);

    fclose(stdin); fclose(stdout);
    return 0;
}

預計分數 A + 30 + 0

實際 A + 0 + 30

T1 可以簡單進行模擬記錄從1到該節點0和1的個數,枚舉以每個點為中?(左邊全為0,右邊全為1),記錄最小值

T2打了個表,編譯超時,這個錯誤還是第一次見,理解錯題意較長時間

T3當時沒時間做,不過想在看std並不是很難

10.26 模擬賽