#include<iostream>#definePIacos(-1.0)#defineINF0x3f3f3f3f#defineLLlonglong#definePairpair<int,int>
LL quickPow(LL a,LL b){ LL res=1;while(b){if(b&1)res*=a; a*=a; b>>=1;}return res;}
LL multMod(LL a,LL b,LL mod){ a%=mod; b%=mod; LL res=0;while(b){if(b&1)res=(res+a)%mod; a=(a<<=1)%mod; b>>=1;}return res%mod;}
LL quickMultPowMod(LL a, LL b,LL mod){ LL res=1,k=a;while(b){if((b&1))res=multMod(res,k,mod)%mod; k=multMod(k,k,mod)%mod; b>>=1;}return res%mod;}
LL quickPowMod(LL a,LL b,LL mod){ LL res=1;while(b){if(b&1)res=(a*res)%mod; a=(a*a)%mod; b>>=1;}return res;}
LL getInv(LL a,LL mod){returnquickPowMod(a,mod-2,mod);}
LL GCD(LL x,LL y){return!y?x:GCD(y,x%y);}
LL LCM(LL x,LL y){return x/GCD(x,y)*y;}constdouble EPS =1E-6;constint MOD =1000000000+7;constint N =1000+5;constint dx[]={0,0,-1,1,1,-1,1,1};constint dy[]={1,-1,0,0,-1,1,-1,1};usingnamespace std;int n;int G[N][N];bool vis[N];int dis[N];int pre[N];int f =1;voidprint(int x){if(x ==0)return;else{print(pre[x]);printf("%d ", x +1);}}intmain(){scanf("%d",&n);memset(dis, INF,sizeof(dis));for(int i =0; i < n; i++){for(int j =0; j < n; j++){scanf("%d",&G[i][j]);if(G[i][j]==0)
G[i][j]= INF;elseif(i ==0)
dis[j]= G[i][j];}}
dis[0]=0;for(int i =0; i < n; i++){int minn = INF, x =0;for(int j =0; j < n; j++)if(!vis[j]&& minn > dis[j])
minn = dis[j], x = j;
vis[x]=1;for(int j =0; j < n; j++){if(G[x][j]+ dis[x]< dis[j]){
pre[j]= x;
dis[j]= G[x][j]+ dis[x];}}}printf("minlong=%d\n", dis[n -1]);printf("1 ");print(n -1);return0;}
三、蓝桥杯 十届 特别数的和
1. 问题描述
2. 问题解决
#include<iostream>usingnamespace std;boolcheck(int n){while(n){int s = n %10;
n /=10;if(s ==1|| s ==2|| s ==9|| s ==0){returntrue;break;}}returnfalse;}intmain(){int m,sum =0;
cin>>m;for(int i =1; i <= m ;i++){if(check(i)) sum += i;}
cout<<sum;return0;}