题解 | #自守数#
自守数
https://www.nowcoder.com/practice/88ddd31618f04514ae3a689e83f3ab8e
#include <iostream> using namespace std; int main() { int a; cin >> a; int count =1; for(int i =1;i <=a; i++){ if(i < 10 && i*(i-1) %10 ==0){ count ++; } if(i >=10 && i<100 && i*(i-1) %100 ==0){ count ++; } if(i >=100 && i <1000 && i*(i-1) %1000 ==0){ count ++; } if(i >=1000 && i <10000 && i*(i-1) %10000 ==0){ count ++; } } cout << count << endl; }