求助

P2657 [SCOI2009] windy 数

@[陶文祥](/space/show?uid=56561) @[AC我最萌](/space/show?uid=80358) @[Miku初音](/space/show?uid=89820) @[emming](/space/show?uid=27793)
by 雪绮晶 @ 2018-08-30 11:23:50


过气蒟蒻路过并%%%
by 宇智波—鼬 @ 2018-08-30 11:25:30


@[雪绮晶](/space/show?uid=110460) %%%您这是要进队啊
by 06ray @ 2018-08-30 11:25:58


@[雪绮晶](/space/show?uid=110460) 下次请@我小号,不要@大号
by Waddles @ 2018-08-30 11:28:19


@[雪绮晶](/space/show?uid=110460) 并且送上鄙人的程序一份(很丑) ``` #include<map> #include<cmath> #include<stack> #include<queue> #include<cstdio> #include<vector> #include<cstring> #include<iostream> #include<algorithm> using namespace std; typedef long long ll; template<class AC>void r(AC &x){ x=0; int f=0; char ch=getchar(); while(ch<'0'||ch>'9'){ f|=(ch=='-'); ch=getchar(); } while(ch>='0'&&ch<='9'){ x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); } x=f?-x:x; return; } int n,m; ll power[1005],f[1005][1005]; void init(){ power[0]=1; for(int i=1;i<=12;i++)power[i]=power[i-1]*10; for(int i=0;i<=9;i++)f[1][i]=1; for(int i=2;i<=11;i++) for(int j=0;j<=9;j++) for(int k=0;k<=9;k++) if(abs(j-k)>=2)f[i][j]+=f[i-1][k]; } int work(int x){ int w=0,ans=0,pre=0; while(power[w]<=x)w++; for(int i=0;i<=9;i++)ans+=f[1][i]; for(int i=1;i<w;i++){ for(int j=1;j<=9;j++){ ans+=f[i][j]; } } int y=x/power[w-1]; for(int j=1;j<y;j++)ans+=f[w][j]; pre=y; x%=power[w-1]; for(int i=w-1;i>=1;i--){ y=x/power[i-1]; for(int j=0;j<y;j++)if(abs(pre-j)>=2)ans+=f[i][j]; if(abs(pre-y)<2)return ans; pre=y; x%=power[i-1]; } return ans; } int main(){ r(n);r(m); init(); cout<<work(m+1)-work(n)<<endl; return 0; } ```
by Waddles @ 2018-08-30 11:29:19


@[陆麟瑞666](/space/show?uid=42443) %%%llr奆佬
by Waddles @ 2018-08-30 11:29:52


@[Song_of_long_voyage](/space/show?uid=119120) 谢谢了
by 雪绮晶 @ 2018-08-30 11:32:09


~~我不会告诉泥萌友链就是大号~~
by Waddles @ 2018-08-30 11:33:18


@[Song_of_long_voyage](/space/show?uid=119120) orz
by 孤独を見守る @ 2018-08-30 11:37:04


@[Song_of_long_voyage](/space/show?uid=119120) 资瓷祥祥大佬
by 孤独を見守る @ 2018-08-30 11:37:18


| 下一页