自己的编译器能过洛谷上tle
查看原帖
自己的编译器能过洛谷上tle
1269423
huge_wave楼主2024/9/4 07:10
#include<bits/stdc++.h>
using namespace std;
const int N=2e3+10;
int a[N][N];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t,k;
	cin>>t>>k;
	a[0][0]=1;
	for(int i=1;i<=2000;i++){
		for(int j=0;j<=i;j++){
			a[i][j]=a[i-1][j-1]+a[i-1][j];
			if(a[i][j]>=k){
				a[i][j]-=k;
			}
		}
	}
	while(t--){
		int n,m,ans=0;
		cin>>n>>m;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=min(i,m);j++){
				if(a[i][j]==0){
					ans++;
				}
			}
		}
		cout<<ans<<"\n";
	}
	return 0;
}            
2024/9/4 07:10
加载中...