4.3w+
社区成员
1、
#include<stdio.h>
int fun(int n){
int sum=0;
while(n){
sum+=n%10;
n/=10;
}
return sum;
}
int main(){
int count=0;
int i,j,year,month,days[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
for(year=1900;year<=9999;year++){
if(year%4==0&&year%100!=0||year%400==0)
days[2]=29;
else
days[2]=28;
for(i=1;i<=12;i++){
for(j=1;j<=days[i];j++){
if(fun(year)==fun(i)+fun(j))count++;
}
}
}
printf("%d",count);
return 0;
}
2、
3、
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
typedef pair<int, int> PII;
const int N = 2e5 + 10;
PII a[N];
int n, m;
bool cmp(const PII a, const PII b)
{
return a.s < b.s;
}
int main()
{
cin >> n >> m;
for(int i = 1; i <= n; i++)
{
a[i].f = i;
a[i].s = i;
}
int res = -1, cnt = 2e6 + 1;
while(m --)
{
char op[2];
int x;
scanf("%s %d", op, &x);
if(op[0] == 'L')
{
a[x].s = res --;
}
else
{
a[x].s = cnt++;
}
}
sort(a + 1, a + n + 1, cmp);
for(int i = 1; i <= n; i++)
{
printf("%d ", a[i].f);
}
return 0;
}