第一次打。。。平台不接受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);
}