The digit sum of a positive integer �n is defined as the sum of the digits in the decimal notation of �n. For example, the digit sum of 20242024 is 2+0+2+4=82+0+2+4=8.
A positive integer �n is called a good integer when �n is divisible by its digit sum. For example, 20242024 is a good integer because it is divisible by its digit sum of 88.
You are given a positive integer �N. How many good integers are less than or equal to �N?
The input is given from Standard Input in the following format:
�N
Print the number of good integers less than or equal to �N.
Copy
20
Copy
13
There are 1313 good integers less than or equal to 2020: 1,2,3,4,5,6,7,8,9,10,12,18,201,2,3,4,5,6,7,8,9,10,12,18,20.
Copy
2024
Copy
409
Copy
9876543210
Copy
547452239
时间超限!
暴搜
int转string
#include
using namespace std;
#pragma GCC optimize(2)
signed main()
{
unsigned long long n,sss=0;
cin>>n;
unsigned long long ttt=0;
for(unsigned long long i=1; i<=n; i++)
{
string iss=std::to_string(i);
for(unsigned long long j=0; j