10.26 模拟赛

#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 + 0

 

T1 可以简单进行模拟记录从1到该节点0和1的个数,枚举以每个点为中❤(左边全为0,右边全为1),记录最小值

T2打了个表,编译超时,这个错误还是第一次见,理解错题意较长时间

T3当时没时间做,不过想在看std并不是很难

posted @ 2017-10-26 19:14  ioioioioioio  阅读(140)  评论(0编辑  收藏  举报