QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#22637#2870. Boris and Bertas8194272#AC ✓41ms3680kbC++141.4kb2022-03-10 14:25:292022-04-30 01:28:45

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-30 01:28:45]
  • 评测
  • 测评结果:AC
  • 用时:41ms
  • 内存:3680kb
  • [2022-03-10 14:25:29]
  • 提交

answer

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<map>
#include<set>

#define int long long
#define fi first
#define se second
#define max Max
#define min Min
#define abs Abs
#define lc (x<<1)
#define rc (x<<1|1)
#define mid ((l+r)>>1)
#define pb(x) push_back(x)
#define lowbit(x) (x&(-x))
#define fan(x) (((x-1)^1)+1)
#define mp(x,y) make_pair(x,y)
#define clr(f,n) memset(f,0,sizeof(int)*(n))
#define cpy(f,g,n) memcpy(f,g,sizeof(int)*(n))
#define INF 0x3f3f3f3f

using namespace std;

inline int read()
{
	int ans=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=(ans<<1)+(ans<<3)+c-'0';c=getchar();}
	return ans*f;
}

inline void write(int x)
{
	if(x<0) putchar('-'),x=-x;
	if(x/10) write(x/10);
	putchar((char)(x%10)+'0');
}

template<typename T>inline T Abs(T a){return a>0?a:-a;};
template<typename T,typename TT>inline T Min(T a,TT b){return a<b?a:b;}
template<typename T,typename TT> inline T Max(T a,TT b){return a<b?b:a;}

int n,a,b,mn,pa,pb;

signed main()
{
	n=read();a=read();b=read();mn=n;
	for(int i=0;i<=2100000;++i)
	{
		int lim=max(0,(n-i*a)/b);
		int st=max(0,lim-3),ed=lim+3;
		for(int j=st;j<=ed;++j)
			if(abs(i*a+j*b-n)<mn)
				mn=abs(i*a+j*b-n),pa=i,pb=j;
	}
	write(pa);putchar(' ');write(pb);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 33ms
memory: 3520kb

input:

1234
500
169

output:

0 7

result:

ok 

Test #2:

score: 0
Accepted
time: 35ms
memory: 3584kb

input:

1700
500
200

output:

1 6

result:

ok 

Test #3:

score: 0
Accepted
time: 35ms
memory: 3528kb

input:

12345
11299
220

output:

0 56

result:

ok 

Test #4:

score: 0
Accepted
time: 32ms
memory: 3528kb

input:

10000
1000
200

output:

0 50

result:

ok 

Test #5:

score: 0
Accepted
time: 36ms
memory: 3592kb

input:

10000
1000
213

output:

10 0

result:

ok 

Test #6:

score: 0
Accepted
time: 36ms
memory: 3656kb

input:

1
500
169

output:

0 0

result:

ok 

Test #7:

score: 0
Accepted
time: 36ms
memory: 3564kb

input:

1099
900
200

output:

1 1

result:

ok 

Test #8:

score: 0
Accepted
time: 36ms
memory: 3592kb

input:

1100
900
200

output:

1 1

result:

ok 

Test #9:

score: 0
Accepted
time: 32ms
memory: 3680kb

input:

1101
900
200

output:

1 1

result:

ok 

Test #10:

score: 0
Accepted
time: 34ms
memory: 3680kb

input:

1795
900
220

output:

2 0

result:

ok 

Test #11:

score: 0
Accepted
time: 36ms
memory: 3656kb

input:

8584
11299
169

output:

0 51

result:

ok 

Test #12:

score: 0
Accepted
time: 38ms
memory: 3564kb

input:

85
4845
169

output:

0 1

result:

ok 

Test #13:

score: 0
Accepted
time: 37ms
memory: 3588kb

input:

87
7653
170

output:

0 1

result:

ok 

Test #14:

score: 0
Accepted
time: 36ms
memory: 3564kb

input:

170
6477
169

output:

0 1

result:

ok 

Test #15:

score: 0
Accepted
time: 36ms
memory: 3532kb

input:

172
8962
169

output:

0 1

result:

ok 

Test #16:

score: 0
Accepted
time: 36ms
memory: 3448kb

input:

431
500
169

output:

1 0

result:

ok 

Test #17:

score: 0
Accepted
time: 36ms
memory: 3568kb

input:

1344361
11299
220

output:

80 2002

result:

ok 

Test #18:

score: 0
Accepted
time: 32ms
memory: 3664kb

input:

2474261
11299
220

output:

38 9295

result:

ok 

Test #19:

score: 0
Accepted
time: 32ms
memory: 3532kb

input:

3514830
11220
220

output:

0 15976

result:

ok 

Test #20:

score: 0
Accepted
time: 29ms
memory: 3572kb

input:

115004670
11220
220

output:

0 522748

result:

ok 

Test #21:

score: 0
Accepted
time: 36ms
memory: 3568kb

input:

10
7013
212

output:

0 0

result:

ok 

Test #22:

score: 0
Accepted
time: 36ms
memory: 3568kb

input:

766
3734
209

output:

0 4

result:

ok 

Test #23:

score: 0
Accepted
time: 32ms
memory: 3568kb

input:

22162
6263
196

output:

0 113

result:

ok 

Test #24:

score: 0
Accepted
time: 36ms
memory: 3584kb

input:

8174031
7921
172

output:

123 41859

result:

ok 

Test #25:

score: 0
Accepted
time: 36ms
memory: 3588kb

input:

31647263
4029
184

output:

155 168602

result:

ok 

Test #26:

score: 0
Accepted
time: 33ms
memory: 3648kb

input:

361366292
10173
185

output:

64 1949812

result:

ok 

Test #27:

score: 0
Accepted
time: 36ms
memory: 3568kb

input:

977906491
8351
216

output:

101 4523440

result:

ok 

Test #28:

score: 0
Accepted
time: 41ms
memory: 3648kb

input:

999999983
502
172

output:

32 5813860

result:

ok 

Test #29:

score: 0
Accepted
time: 36ms
memory: 3648kb

input:

999999993
11296
218

output:

44 4584876

result:

ok 

Test #30:

score: 0
Accepted
time: 41ms
memory: 3528kb

input:

1000000000
500
169

output:

54 5917000

result:

ok 

Test #31:

score: 0
Accepted
time: 36ms
memory: 3564kb

input:

1000000000
11299
220

output:

60 4542373

result:

ok