Atcoder#53

第一次打。。。平台不接受I64d 只能lld。。。wa了11次。。。
D题:
每次随便取三个数,最大最小扔掉,中间的放回去,问最后最多剩下多少互相不相同的数。。。可以知道,只要出现多次的。。他和他本身一起拿出来,那他本身一定会留下来一个,另一个扔掉,于是所有重复的数字,一共是偶数的话,就可以所有数字都个留下来一个,否则-1.

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 1e5+10;
int n,cnt,kin;
int a[maxn],st[maxn];
int read(){
    int res = 0;
    int flag = 0;
    char ch;
    if ((ch = getchar()) == '-'){
        flag = 1;
    }
    else if(ch >= '0' && ch <= '9'){
        res = ch - '0';
    }
    while ((ch = getchar()) >= '0' && ch <= '9'){
        res = res * 10 + (ch - '0');
    }
    return flag ? -res : res;
}
void init(){
    scanf("%d",&n);
    for(int i = 0 ; i < n ; i++)
        a[i] = read();
    sort(a,a+n);
    cnt = 0;
    kin = 1;
    for(int i = 1 ; i < n ; i++){
        if(a[i] == a[i-1])
            st[++cnt] = a[i];
        else    kin++;
    }
    int ans  =0;
    if(cnt %2 == 0) ans = kin;
    else    ans = kin-1;
    printf("%d\n",`
ns);
}

int main(){
    init();
}

C”

#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int maxn = 2e5+10;
long long n;
int main(){
    cin>>n;
    long long ans = (n/11)*2;
    if(n% 11 == 0)   ans = ans;
    else if(n%11 <= 6 )   ans = ans+1;
    else   ans = ans+2;
    cout << ans<<endl;
}

B

#include <cstdio>
#include <cstring>
using namespace std;
const int maxn = 2e5+10;
char s[maxn];
int main(){
    int st,rn;
    scanf("%s",s);
    for(int i = 0 ; i < strlen(s);i++)
    if(s[i]=='A'){
        st = i;
        break;
    }
    for(int i = strlen(s)-1; i >= 0 ;i--)
    if(s[i] == 'Z'){
        rn = i;
        break;
    }
    if(rn < st) printf("0\n");
    else
    printf("%d\n",rn-st+1);
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值