Compare commits

..

2 Commits

Author SHA1 Message Date
Martin e66d8fd58f 加入了 幸运数.cpp
2 months ago
pvexk5qol f66c1356be Update README.md
2 months ago

@ -1,2 +1,2 @@
# test
##test

@ -0,0 +1,40 @@
#include <bits/stdc++.h>
using namespace std;
int ans=9;
int main(){
for (int i=1000;i<=9999;i++){
int t=i;
int hh=0,tt=0;
for (int j=1;j<=4;j++){
if (j<=2) tt+=t%10,t/=10;
else hh+=t%10,t/=10;
}
if (hh==tt) ans++;
}
for (int i=100000;i<=999999;i++){
int t=i;
int hh=0,tt=0;
for (int j=1;j<=6;j++){
if (j<=3) tt+=t%10,t/=10;
else hh+=t%10,t/=10;
}
if (hh==tt) ans++;
}
for (int i=10000000;i<=99999999;i++){
int t=i;
int hh=0,tt=0;
for (int j=1;j<=8;j++){
if (j<=4) tt+=t%10,t/=10;
else hh+=t%10,t/=10;
}
if (hh==tt) ans++;
}
cout<<ans;
return 0;
}
Loading…
Cancel
Save