数据较弱
查看原帖
数据较弱
1025179
Cuber_release楼主2023/12/1 22:43

本来想着暴力枚举能不能过

写了不到5分钟提交发现居然能过

code:

#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,k;
int sum;
int ans;
inline bool check(int x){
	if((int)sqrt(x) *(int)sqrt(x) == x){
		return true;
	}
	return false;
}
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	cin>>n>>k;
	for(register int i=1;i<=n-k+1;i++){
		int temp=0;
		for(register int j=i;j<=i+k-1;j++){
			temp+=j;
		}
		if(check(temp)){
			ans++;
		}
	}
	cout<<ans;

	return 0;
}

2023/12/1 22:43
加载中...