日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

github 思维导图开元软件_Mymind教学系列--Github上的免费且强大思维导图工具-(一)...

發布時間:2025/3/15 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 github 思维导图开元软件_Mymind教学系列--Github上的免费且强大思维导图工具-(一)... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

How many 0‘s?

Time Limit:?1000MS

Memory Limit:?65536K

Total Submissions:?2844

Accepted:?1506

Description

A Benedict monk No.16 writes down the decimal representations of all natural numbers between and including?m?and?n,?m?≤?n. How many 0‘s will he write down?

Input

Input consists of a sequence of lines. Each line contains two unsigned 32-bit integers?m?and?n,?m?≤?n. The last line of input has the value of?m?negative and this line should not be processed.

Output

For each line of input print one line of output with one integer number giving the number of 0‘s written down by the monk.

Sample Input

10 11

100 200

0 500

1234567890 2345678901

0 4294967295

-1 -1

Sample Output

1

22

92

987654304

3825876150

Source

dp的思路很容易看出來,關鍵是處理好細節,調試了很長時間的代碼。

#include

#include

#include

#include

#include

#define N 30

using namespace std;

__int64 dp1[N],dp2[N];

int dig[N];

int Top;

__int64 ba[N];

int main()

{

//freopen("data.txt","r",stdin);

__int64 f();

memset(dp1,0,sizeof(dp1));

memset(dp2,0,sizeof(dp2));

dp1[1] = dp2[1] = 1;

ba[0] = 1;

ba[1] = 10;

for(int i=2;i<=11;i++)

{

dp1[i] = dp2[i-1]*9;

dp2[i] = 10*dp2[i-1]+ba[i-1];

ba[i] = ba[i-1] * 10;

}

__int64 n,m;

while(scanf("%I64d %I64d",&n,&m)!=EOF)

{

if(n<0)

{

break;

}

Top = 0;

n-=1;

__int64 res1,res2;

if(n==-1)

{

res1 = 0;

}else

{

if(n==0)

{

dig[Top++] = 0;

}

while(n!=0)

{

dig[Top++] = n%10;

n = n/10;

}

res1=f();

}

Top = 0;

if(m==0)

{

dig[Top++] = 0;

}

while(m!=0)

{

dig[Top++] = m%10;

m = m/10;

}

res2 = f();

printf("%I64d\n",res2-res1);

}

return 0;

}

__int64 f()

{

__int64 res = 0;

for(int i=1;i<=Top-1;i++)

{

res+=dp1[i];

}

//cout<

int t;

for(int i=Top-1;i>=0;i--)

{

if(i==Top-1&&Top>1)

{

t = 1;

}else

{

t = 0;

}

for(int j=t;j<=dig[i]-1;j++)

{

res+=dp2[i];

if(j==0)

{

res+=ba[i];

}

}

}

for(int i=Top-1;i>=0;i--)

{

if(dig[i]==0)

{

__int64 sum = 0;

for(int j=i-1;j>=0;j--)

{

sum = sum*10+dig[j];

}

sum+=1;

res+=sum;

}

}

return res;

}

原文:http://blog.csdn.net/crper/article/details/20155953

總結

以上是生活随笔為你收集整理的github 思维导图开元软件_Mymind教学系列--Github上的免费且强大思维导图工具-(一)...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。