1 |
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
int i,j,cmt=0;
for(i=1002; i<=1998; i++) {
int a[10]= {0},cnt=0;
j=i;
while(j) {
a[j%10]++;
if(a[j%10]>=2) {
cnt+=a[j%10]>2?-1:1;
}
j/=10;
}
if(cnt==1)
cmt++;
}
cout<<cmt<<endl;
return 0;
}
#include<iostream> using namespace std; int main() { int num = 0; for (int i = 1000; i < 1999;i++) { int a = i / 1000; int b = (i %1000) / 100; int c = i % 1000 % 100/10; int d = i - 1000 - b * 100 - c * 10; if ((a == b&&a != c&&a != d&&c!=d) || (a == c&&a != b&&a != d&&b!=d) || (a == d&&a != b&&a != c&&b!=c) || (b == c&&b != d&&a != d&&b!=a) || (b == d&&c != a&&b != c&&b!=a) || (d == c&&b != a&&b != c&&c!=a)) { num++; } } cout << num << endl; return 0; }