## Siukwan Program

http://siukwan.sinaapp.com/

# 1049. Counting Ones (30)

1.和leetcode里面的Number of Digit One一样

2.算法说明：

AC代码：

#include <iostream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <algorithm>
#include <memory.h>
#include <map>
#include <set>
#include "limits.h"
using namespace std;

int main(void)
{
long long n;
cin>>n;
long long ans = 0;
for(long long digitDivide=1;digitDivide<=n;digitDivide*=10)
{
long long a = n / digitDivide;
long long b = n%digitDivide;
ans+=(a+8)/10*digitDivide+(a%10==1)*(b+1);
}
cout<<ans<<endl;

return 0;
}

#### 【PAT 1049】 Counting Ones 数学规律

2014-02-25 13:18:07

#### pat1049Counting Ones (30)

2015-10-16 18:16:22

#### 1049. Counting Ones (30)计算个位数出现次数.

2016-03-10 14:01:49

#### 1049. Counting Ones 解析

2017-07-12 23:36:03

#### PAT_A 1049. Counting Ones (30)

2017-09-05 22:14:30

#### 1049. Counting Ones (30) --看

2015-07-19 11:09:33

#### PAT 1049. Counting Ones (30)

2014-03-11 10:27:56

#### 1049. Counting Ones (30) (搜索)

2015-12-02 21:15:58

#### 【PAT】1049. Counting Ones (30)

2015-11-04 20:28:47

#### 1049. Counting Ones (30)解题报告

2016-10-29 13:11:12