标签:false src 图片 lse png with ble integer pac
A.
被卡了好久,样例的第一感觉n%k==0则YES
后来写式子,交了发n>=k*k 虽然写的时候也注意到了n-k必须是偶数(k个奇数和的奇偶性与k相同,故n与k奇偶性相同)
最后才想到,可以构造 前k-1个数为1~k-1 剩下的即为第k个数
#include<bits/stdc++.h> #define ll long long using namespace std; //const int N=1e4+5; int main(){ int T; ios::sync_with_stdio(false);cin.tie(0); cin>>T; while(T--){ ll n,k; cin>>n>>k; if(n>=k*k&&n%2==k%2)cout<<"YES"<<endl; else cout<<"NO"<<endl; } return 0; }
比赛时交的
#include<bits/stdc++.h> #define ll long long using namespace std; //const int N=1e4+5; int main(){ int T; ios::sync_with_stdio(false);cin.tie(0); cin>>T; while(T--){ ll n,k; cin>>n>>k; if((n-(k-1)*(k-1))%2&&(n-(k-1)*(k-1))>=2*k-1)cout<<"YES"<<endl; else cout<<"NO"<<endl; } return 0; }
B
Educational Codeforces Round 84 (Rated for Div. 2), problem: (A) Sum of Odd Integers
标签:false src 图片 lse png with ble integer pac
原文地址:https://www.cnblogs.com/wyh447154317/p/12568503.html