c++,2、5、8WA,救救孩子
查看原帖
c++,2、5、8WA,救救孩子
1289665
ShinnoKokoro楼主2024/3/7 19:42
#include<iostream>
using namespace std;
int main() {
	int  n, x,count;
	cin >> n >> x;
	if (n < x) {
		cout << "0";
		return 0;
	}
	else {
		if (n >= x && n < 10) {
			cout << "1";
			return 0;
		}
		else {
			count = 1;
			for (int i = 10; i <= n; i++) {
				int j = 10;
				while (j <= i) {
					if (i % j / (j / 10) == x) {
						count++;
					}
					if (i / j == x&&i/j!=0) {
						count++;
					}
					j *= 10;
				}
			}
		}
	}
	cout << count << endl;
	return 0;
}
2024/3/7 19:42
加载中...