AtCoder Beginner Contest 336 E题解

Problem Statement

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?

Constraints

  • 1≤�≤10141≤N≤1014
  • �N is an integer.

Input

The input is given from Standard Input in the following format:

�N

Output

Print the number of good integers less than or equal to �N.


Sample Input 1Copy

Copy

20

Sample Output 1Copy

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.


Sample Input 2Copy

Copy

2024

Sample Output 2Copy

Copy

409

Sample Input 3Copy

Copy

9876543210

Sample Output 3Copy

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

你可能感兴趣的:(c++)