日期统计:
暴力枚举+set(自带排序加去重)
#include<iostream>
#include<set>
using namespace std;
set<int>ans;
int a[100]={5 ,6, 8, 6 ,9 ,1, 6, 1, 2, 4, 9, 1, 9, 8 ,2 ,3 ,6 ,4 ,7, 7, 5, 9 ,5, 0, 3, 8, 7, 5, 8, 1, 5, 8, 6, 1, 8, 3, 0, 3, 7, 9, 2,7, 0, 5, 8 ,8 ,5 ,7, 0, 9, 9, 1, 9, 4, 4 ,6 ,8, 6, 3, 3, 8, 5, 1, 6, 3, 4, 6, 7, 0, 7, 8, 2, 7, 6, 8, 9, 5, 6, 5, 6, 1, 4, 0, 1,
0, 0, 9, 4, 8, 0, 9, 1, 2, 8, 5, 0, 2, 5, 3, 3};
int months[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
bool check(int m,int d){
if(!m||!d||m>12) return false;
if(d>months[m]) return false;
return true;
}
int main(){
for(int i1=0;i1<93;i1++){
if(a[i1]==2){
for(int i2=i1+1;i2<94;i2++){
if(a[i2]==0){
for(int i3=i2+1;i3<95;i3++){
if(a[i3]==2){
for(int i4=i3+1;i4<96;i4++){
if(a[i4]==3){
for(int i5=i4+1;i5<97;i5++){
for(int i6=i5+1;i6<98;i6++){
for(int i7=i6+1;i7<99;i7++){
for(int i8=i7+1;i8<100;i8++){
if(i1!=i2&&i2!=i3&&i3!=i4&&i4!=i5&&i5!=i6&&i6!=i7&&i7!=i8){
if(check(10*a[i5]+a[i6],10*a[i7]+a[i8])){
int temp=100*(10*a[i5]+a[i6])+10*a[i7]+a[i8];
ans.insert(temp);
}
}
}
}
}
}
}
}
}
}
}
}
}
}
cout<<ans.size()<<endl;
return 0;
}
01串的熵:
暴力枚举
在判断时注意两者差的绝对值小于1e-4
#include<iostream>
#include<cmath>
using namespace std;
int main(){
int n=23333333;
for(int i=0;i<=n/2;i++){
double a=1.0*i/n;
double b=1.0*(n-i)/n;
double ans=0.0;
ans=(-1)*i*a*log2(a)+(-1)*(n-i)*b*log2(b);
if(abs(ans-11625907.5798)<1e-4){
cout<<i<<endl;
break;
}
}
return 0;
}
标签:return,int,填空题,30,c++,蓝桥,false,include,31
From: https://blog.csdn.net/2301_76144982/article/details/137470998