为什么会TLE啊啊啊!!(50分)
查看原帖
为什么会TLE啊啊啊!!(50分)
1444395
McdullWang楼主2024/12/17 20:35
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n,k,t,s=1,temp,zonghe=0,total=0;
	cin>>t;
	for(int i=1;i<=t;i++){
		cin>>n>>k;
		for(int j=1;j<=n;j++){
			s*=10;
		}
		for(int w=1;w<=s;w++){
			temp=w;
			while(temp>0){
				zonghe+=temp%10;
				temp/=10;
			}
			if(zonghe<=k){
				total++;
			}
			zonghe=0;
		}
		s=1;
		cout<<total-1<<endl;
		total=0;
	} 
	return 0;
} 
2024/12/17 20:35
加载中...