第三届上海市青少年算法竞赛题解
T1 数洞洞
#include<bits/stdc++.h>
using namespace std;
int a[11]={
0,1,0,0,0,1,0,1,0,2,1},num=0;
int n;
int main()
{
cin>>n;
while(n!=0)
{
int t=n%10;
n/=10;
num+=a[t+1];
}
cout<<num;
return 0;
}
T2 中位数
#include<bits/stdc++.h>
using namespace std;
const long long MAXN=3*1e5+20;
long long n,a[MAXN],num;
bool cmp(long long a,long long b)
{
if(a>b)
{
return true;
}
else
{
return false;
}
}
int main()
{
scanf("%lld",&n);
for(int i=1;i<=3*n;i++)
{
scanf("%lld",&a[i]);