The Major Oak in Sherwood is known for its majestic foliage, which provided shelter to…
- User
The Major Oak in Sherwood is known for its majestic foliage, which provided shelter to Robin Hood and his band of merry men and women.
The Major Oak grows ii new leaves in the i -th year. It starts with 1 leaf in year 1 .
Leaves last for k years on the tree. In other words, leaves grown in year i last between years i and i+k−1 inclusive.
Robin considers even numbers lucky. Help Robin determine whether the Major Oak will have an even number of leaves in year n .
Input The first line of the input contains a single integer t (1≤t≤104 ) — the number of test cases.
Each test case consists of two integers n , k (1≤n≤109 , 1≤k≤n ) — the requested year and the number of years during which the leaves remain.
Output For each test case, output one line, "YES" if in year n the Major Oak will have an even number of leaves and "NO" otherwise.
You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.
include
include
include
include
using namespace std;
bool comp(int a,int b) { return b>a; }
bool calc(int n,int k) { long long total_leaves=0; for(int i=1;i<=n;i++) { total_leaves+=pow(i,i); }
codefor(int i=1;i<=n;i++) { if(n>i+k-1) total_leaves-=pow(i,i); } return (total_leaves)%2;}
void process_test_case() { int size=0,k=0; cin>>size; cin>>k; if(calc(size,k)) cout<<"NO"<<endl; else cout<<"YES"<<endl; }
int main() { int T; cin >> T;
codefor (int i = 0; i < T; i++) { process_test_case(); } return 0;}
correct the code if can be done
- Assistant