QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#275295#7795. 茧yyyyxh5 5ms2220kbC++232.5kb2023-12-04 16:23:412023-12-04 16:23:42

Judging History

你现在查看的是最新测评结果

  • [2023-12-04 16:23:42]
  • 评测
  • 测评结果:5
  • 用时:5ms
  • 内存:2220kb
  • [2023-12-04 16:23:41]
  • 提交

answer

#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll read(){
	char c=getchar();ll x=0;
	while(c<48||c>57) c=getchar();
	do x=(x<<1)+(x<<3)+(c^48),c=getchar();
	while(c>=48&&c<=57);
	return x;
}
const ll INF=0x3f3f3f3f3f3f3f3f;
const int N=100003;
inline int qp(int a,int b){
	int res=1;
	while(b) --b,res*=a;
	return res;
}
ll a[N];
int k;
ll qry(ll x){
	if(x==1) return 1;
	if(x==0||x==2) return 0;
	if(x&1) return ((x+1)>>1);
	else return qry(x-((x+3)>>1));
}
ll sol(ll x){
	if(!x) return 0;
	ll p=sqrt(x);
	while(p*p<=x) ++p;
	while(p*p>x) --p;
	ll t=x-p*p;
	if(t>p) t-=p+1;
	if(!t) return p;
	p-=t>>1;
	if(t&1){
		if(p<=4) return p==3;
		return qry(p-2);
	}
	else return p;
}
int f[N+3],g[N+3];
bool vis[N+3];
ll go(ll x){
	ll p=pow(x,1.0/3);
	while(p*p*p<=x) ++p;
	while(p*p*p>x) --p;
	ll t=x-p*p*p;
	if(!t) return p;
	return (t-1)%(p+1);
}
ll pps(ll p,ll t){
	t%=(p+1);
	if(!t) return p;
	t-=p+1;
	t+=p*p*p*p;
	--p;
	return pps(p,t-p*p*p*p);
}
ll ps(ll x){
	ll p=sqrt(sqrt(x));
	while(qp(p,4)<=x) ++p;
	while(qp(p,4)>x) --p;
	ll t=x-qp(p,4);
	return pps(p,t);
}
ll rush(ll x){
	ll p=pow(x,1.0/5);
	while(qp(p,5)<=x) ++p;
	while(qp(p,5)>x) --p;
	ll t=x-qp(p,5);
	if(!t) return p;
	return (t-1)%(p+1);
}
void solve(){
	if(k==1){
		int n=read();
		ll cur=0;
		while(n--){
			ll x=read();
			switch(x%4){
			case 0:cur^=x;break;
			case 1:cur^=1;break;
			case 2:cur^=x+1;break;
			}
		}
		if(cur) puts("Lily");
		else puts("Kaguya");
		return;
	}
	bool fl=1;
	int n=read();
	for(int i=1;i<=n;++i) a[i]=read(),fl&=a[i]<=N;
	if(fl){
		int cur=0;
		for(int i=1;i<=n;++i) cur^=g[a[i]];
		if(cur) puts("Lily");
		else puts("Kaguya");
		return;
	}
	if(k==2){
		ll cur=0;
		for(int i=2;i<=n;i+=2) cur^=sol(a[i]);
		if(cur) puts("Lily");
		else puts("Kaguya");
		return;
	}
	if(k==3){
		ll cur=0;
		for(int i=2;i<=n;i+=2) cur^=go(a[i]);
		if(cur) puts("Lily");
		else puts("Kaguya");
		return;
	}
	if(k==4){
		ll cur=0;
		for(int i=2;i<=n;i+=2) cur^=ps(a[i]);
		if(cur) puts("Lily");
		else puts("Kaguya");
		return;
	}
	if(k==5){
		ll cur=0;
		for(int i=2;i<=n;i+=2) cur^=rush(a[i]);
		if(cur) puts("Lily");
		else puts("Kaguya");
		return;
	}
}
int main(){
	int tc=read();
	k=read();
	if(k>1){
		for(int i=1,j=0;i<=N;++i){
			while(qp(j+1,k)<=i) ++j;
			if(qp(j,k)==i) f[i]=j;
			else f[i]=f[i-j-1];
		}
	}
	while(tc--) solve();
	return 0;
}

詳細信息

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 5ms
memory: 1656kb

input:

1136 1
1
113619249930092995
2
457093394163961514 36523281
2
52273 586907144813890981
149
13412372218 128311326 618178541606515600 756479282467845696 276251850291230545 978441742104676009 1035439042005099 1105099328508110145 981121546786695466 97032240925148816 171 149766413231751232 28137602525069 9...

output:

Kaguya
Lily
Kaguya
Lily
Lily
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Lily
Kaguya
Kaguya
Kaguya
Lily
Lily
Lily
Lily
Kaguya
Kaguya
Lily
Lily
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Lily
Kaguya
Lily
Kaguya
Kaguya
Kaguya
Lily
Kaguya
Lily
Kaguya
Kaguya
Lily
L...

result:

ok 1136 tokens

Subtask #2:

score: 0
Wrong Answer

Test #2:

score: 0
Wrong Answer
time: 2ms
memory: 2084kb

input:

9868 2
6
45196 27174 14224 5578 40059 47649
8
38740 7 56634 37760 43117 57202 349 102
7
47 498 25922 50544 13 48434 12
11
59314 45 4091 47301 3701 38642 253 11 48627 30158 36
4
1209 43050 22162 22239
12
5 64446 660 18577 46228 48927 6 47617 55178 30917 45801 8
8
60993 148 109 37947 19683 2613 3278 1...

output:

Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya...

result:

wrong answer 10th words differ - expected: 'Lily', found: 'Kaguya'

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Wrong Answer

Test #10:

score: 0
Wrong Answer
time: 0ms
memory: 2052kb

input:

500 2
2
37980539 37980540
2
193 194
2
643 644
2
3409676912 3409676913
2
537559 537560
2
374273640 374273641
2
7 8
2
3795849784 3795849785
2
79614 79615
2
3438078922 3438078923
2
3757510845 3757510846
2
1 2
2
1824633835 1824633836
2
1 2
2
55 56
2
714486861 714486862
2
2772062264 2772062265
2
14788368...

output:

Kaguya
Kaguya
Kaguya
Kaguya
Lily
Kaguya
Kaguya
Kaguya
Kaguya
Lily
Lily
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Lily
Kaguya
Lily
Kaguya
Kaguya
Kaguya
Lily
Kaguya
Lily
Kaguya
Lily
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Lily
Lily
Kaguya
Kaguya
Kaguya
Kaguya
Kaguy...

result:

wrong answer 9th words differ - expected: 'Lily', found: 'Kaguya'

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Wrong Answer

Test #16:

score: 0
Wrong Answer
time: 5ms
memory: 2092kb

input:

1169 2
98
2052761 2052762 861925831649843897 861925831649843898 1031265876706940814 1031265876706940815 617144630657193626 617144630657193627 72 73 138103 138104 156743812713553 156743812713554 205151719721047118 205151719721047119 1065302803446555430 1065302803446555431 1545284063203 1545284063204 ...

output:

Kaguya
Kaguya
Kaguya
Lily
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Lily
Kaguya
Kaguya
Kaguya
Kaguya
Lily
Kaguya
Kaguya
Kaguya
Lily
Kaguya
Kaguya
Kaguya
Kaguya
Lily
Lily
Lily
Lily
Lily
Kaguya
Lily
Kaguya
Kaguya
Kaguya
Kaguya
Lily
Lily
Lily
Kaguya
Lily
Lily
Lily
Kaguya
Kaguya
Lily
Kaguya
Kaguya
Kaguy...

result:

wrong answer 659th words differ - expected: 'Lily', found: 'Kaguya'

Subtask #7:

score: 0
Wrong Answer

Test #17:

score: 0
Wrong Answer
time: 5ms
memory: 2176kb

input:

1775 3
56
1113086767934729403 1113086767934729404 395289496182979739 395289496182979740 1036610723921853591 1036610723921853592 273906 273907 1081906643487536771 1081906643487536772 442413497681636481 442413497681636482 13354476004 13354476005 477736247131002 477736247131003 6159425067 6159425068 5 ...

output:

Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Lily
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Lily
Lily
Kaguya
Lily
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Lily
Kaguya
Kaguya
Kaguya
Lily
Kaguya
Kaguya
Kaguya
Kaguya
Lily
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya
Kaguya...

result:

wrong answer 1089th words differ - expected: 'Lily', found: 'Kaguya'

Subtask #8:

score: 0
Wrong Answer

Test #18:

score: 0
Wrong Answer
time: 0ms
memory: 2044kb

input:

47 2
15
226 33559 101516630 2758718 1497465096 143 10221 19229493 2 19317677 2599390763 2043194 462237450 4045936184 209655973
24
1951804242 97 1448079073 419079478 1033169500 1875 2482 2350383606 16 3958107653 2574141589 2934502110 2036 2574986227 1794970348 4009429601 2844472951 155702147 18791465...

output:

Lily
Lily
Lily
Lily
Lily
Lily
Kaguya
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily

result:

wrong answer 2nd words differ - expected: 'Kaguya', found: 'Lily'

Subtask #9:

score: 0
Wrong Answer

Test #19:

score: 0
Wrong Answer
time: 0ms
memory: 2220kb

input:

71 3
20
1902494844 129105842 1836429008 2862717739 3767166853 2686186537 1099034 40 344827 734438640 2231265370 2818449793 114955743 540338925 553099374 9179 2122555208 580 371 1909359957
30
18 2762110981 262509769 2811288568 3618225103 47784509 255418873 4040384827 159350 87784115 1619856413 8813 1...

output:

Lily
Lily
Lily
Lily
Lily
Kaguya
Lily
Kaguya
Lily
Lily
Lily
Kaguya
Kaguya
Kaguya
Kaguya
Lily
Lily
Lily
Kaguya
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Kaguya
Lily
Lily
Lily
Kaguya
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Lily
Kaguya
Lily
Lily
Kaguya
Lily
Kaguya
Lily
Kaguya...

result:

wrong answer 1st words differ - expected: 'Kaguya', found: 'Lily'

Subtask #10:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #3:

0%