Compare commits
2 Commits
main
...
branch_loc
| Author | SHA1 | Date |
|---|---|---|
|
|
e66d8fd58f | 2 months ago |
|
|
f66c1356be | 2 months ago |
@ -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…
Reference in new issue