QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#328491#7881. Computational Complexityhy233WA 27ms7780kbC++141.7kb2024-02-15 20:29:202024-02-15 20:29:21

Judging History

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

  • [2024-02-15 20:29:21]
  • 评测
  • 测评结果:WA
  • 用时:27ms
  • 内存:7780kb
  • [2024-02-15 20:29:20]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1000005;
const int inf=1e9;
inline ll rd()
{
	ll x=0; bool f=1;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())
		if(ch=='-') f=0;
	for(;ch>='0'&&ch<='9';ch=getchar())
		x=x*10+(ch^48);
	return f?x:-x;
}
ll mod;
struct Node
{
	ll l,r;
	ll x;
	inline bool operator<(const Node t) const
	{ return r<t.r; }
};
set<Node> f,g;
inline Node fndf(ll x)
{
	return *f.lower_bound({0,x,0});
}
inline Node fndg(ll x)
{
	return *g.lower_bound({0,x,0});
}
int main()
{
	int f0=rd(),g0=rd(),t=rd();
	mod=rd();
	f.insert({0,0,f0%mod});
	g.insert({0,0,g0%mod});
	ll cnt=0;
	while((*f.rbegin()).r<=1e15||(*g.rbegin()).r<=1e15)
	{
		cnt++;
		if((*f.rbegin()).r<=(*g.rbegin()).r)
		{
			ll now=(*f.rbegin()).r+1;
			Node p=fndg(now/2);
			ll res=p.x;
			ll nr=(p.r+1)*2;
			p=fndg(now/3);
			res+=p.x;
			nr=min(nr,(p.r+1)*3);
			p=fndg(now/5);
			res+=p.x;
			nr=min(nr,(p.r+1)*5);
			p=fndg(now/7);
			res+=p.x;
			nr=min(nr,(p.r+1)*7);
			if(now<=11&&res<now)
				f.insert({now,now,now});
			else
			{
				if(now>11)
					res%=mod;
				f.insert({now,nr-1,res});
			}
		}
		else
		{
			ll now=(*g.rbegin()).r+1;
			Node p=fndf(now/2);
			ll res=p.x;
			ll nr=(p.r+1)*2;
			p=fndf(now/3);
			res+=p.x;
			nr=min(nr,(p.r+1)*3);
			p=fndf(now/4);
			res+=p.x;
			nr=min(nr,(p.r+1)*4);
			p=fndf(now/5);
			res+=p.x;
			nr=min(nr,(p.r+1)*5);
			if(now<=11&&res<now)
				g.insert({now,now,now});
			else
			{
				if(now>11)
					res%=mod;
				g.insert({now,nr-1,res});
			}
		}
	}
	while(t--)
	{
		ll x=rd();
		Node ff=fndf(x),gg=fndg(x);
		printf("%lld %lld\n",ff.x%mod,gg.x%mod);
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 24ms
memory: 7676kb

input:

1958 920 10 100000000000
0
1
2
3
10
100
200
1000
19580920
20232023

output:

1958 920
3680 7832
10592 9554
17504 11276
50294 64826
784112 893714
1894550 1905470
12057866 12979424
71481494756 48626708512
28127864908 7251681354

result:

ok 20 numbers

Test #2:

score: 0
Accepted
time: 27ms
memory: 7780kb

input:

0 0 10 100000000000
0
1
2
3
4
10
20
30
40
100

output:

0 0
1 1
2 2
3 3
4 4
11 12
25 26
41 41
55 58
162 172

result:

ok 20 numbers

Test #3:

score: -100
Wrong Answer
time: 27ms
memory: 7780kb

input:

2023 2023 10 2023
0
1
2
3
4
5
6
7
8
9

output:

0 0
1 1
2 2
3 3
4 4
5 5
6 7
7 7
8 9
9 10

result:

wrong answer 3rd numbers differ - expected: '0', found: '1'