QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#22634#2870. Boris and Bertaha114514ha#AC ✓26ms3732kbC++203.0kb2022-03-10 14:22:462022-04-30 01:28:35

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:35]
  • 评测
  • 测评结果:AC
  • 用时:26ms
  • 内存:3732kb
  • [2022-03-10 14:22:46]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
#include<queue>
#include<vector>
#include<map>
#include<bitset>
#include<set>
#include<cmath>
#include<ctime>
#include<random>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define bc(x) __builtin_popcount(x)
#define re register
#define il inline
#define pii pair<int,int>
#define pil pair<int,long long>
#define pll pair<long long,long long>
#define mem0(x) memset(x,0,sizeof(x))
#define mem0x3f(x) memset(x,0x3f,sizeof(x))
#define dbg(x) cerr<<"In Line "<< __LINE__<<" the "<<#x<<" = "<<x<<'\n';
#define dpi(x,y) cerr<<"In Line "<<__LINE__<<" the "<<#x<<" = "<<x<<" ; "<<"the "<<#y<<" = "<<y<<'\n';
// #pragma GCC optimize(3)
#define int long long
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
namespace IO_BUFF{
	mt19937 rnd(time(0)^(ll)(new char));
	int rend(int x){
		return rnd()%x+1;
	}
	void rendom_shuffle(int *a,int len){
		shuffle(a+1,a+len+1,rnd);
	}
	const int BS=(1<<24)+5;char Buffer[BS],*HD,*TL;
	inline int gc(){
	    if(HD==TL) TL=(HD=Buffer)+fread(Buffer,1,BS,stdin);
	    return (HD==TL)?EOF:*HD++;
	}
	inline int inn(){
	    int x,ch,s=1;while((ch=gc())<'0'||ch>'9')if(ch=='-')s=-1;x=ch^'0';
	    while((ch=gc())>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^'0');return x*s;
	}
	char ssss[19999999],tttt[20];int ssl,ttl;
    inline int print(int x)
    {
        if(x<0)ssss[++ssl]='-',x=(-x);
		if(!x) ssss[++ssl]='0';for(ttl=0;x;x/=10) tttt[++ttl]=char(x%10+'0');
        for(;ttl;ttl--) ssss[++ssl]=tttt[ttl];return ssss[++ssl]='\n';
    }
	inline int Flush(){return fwrite(ssss+1,sizeof(char),ssl,stdout),ssl=0,0;}
	int read(){
		char c=getchar();int x=1;int s=0;
		while(c<'0' || c>'9'){if(c=='-')x=-1;c=getchar();}
		while(c>='0' && c<='9'){
			s=s*10+c-'0';c=getchar();
		}
		return s*x;
	}
}using namespace IO_BUFF;
/*namespace CFConTest{
	const int mod=998244353;
	inline int add(const int &x,const int &y){
		return (x+y>=mod?x+y-mod:x+y);
	}
	inline int del(const int &x,const int &y){
		return (x-y<0?x-y+mod:x-y);
	}
	int ksm(int x,int k){
		int base=1;
		while(k){
			if(k&1)base=1ll*base*x%mod;
			k>>=1;
			x=1ll*x*x%mod;
		}
		return base;
	}
};
using namespace CFConTest;*/
int n,m,c;
int check(int x,int y){
	return abs(x*m+c*y-n);
}
signed main(){
	#ifdef newbiewzs
		double startt=clock();
		freopen("data.in","r",stdin);
	#else
	#endif
	n=read();m=read();c=read();
	int ans=1e15;
	int sx=0,sy=0;
	for(int i=0;i<=ceil(1.0*n/m)+5;i++){
		int kel=(n-(i*m))/c;
		kel=max(kel,0ll);
		if(check(i,kel)<ans){
			ans=check(i,kel);
			sx=i;
			sy=kel;
		}
		kel++;
		if(check(i,kel)<ans){
			ans=check(i,kel);
			sx=i;
			sy=kel;
		}
		kel-=2;
		kel=max(kel,0ll);
		if(check(i,kel)<ans){
			ans=check(i,kel);
			sx=i;
			sy=kel;
		}
	}
	cout<<sx<<" "<<sy<<'\n';
    #ifdef newbiewzs
		double endd=clock();
		cerr<<'\n';
		cerr<<"Time:"<<endd-startt<<" ms"<<'\n';
	#endif
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3540kb

input:

1234
500
169

output:

0 7

result:

ok 

Test #2:

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

input:

1700
500
200

output:

1 6

result:

ok 

Test #3:

score: 0
Accepted
time: 3ms
memory: 3604kb

input:

12345
11299
220

output:

0 56

result:

ok 

Test #4:

score: 0
Accepted
time: 1ms
memory: 3580kb

input:

10000
1000
200

output:

0 50

result:

ok 

Test #5:

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

input:

10000
1000
213

output:

10 0

result:

ok 

Test #6:

score: 0
Accepted
time: 2ms
memory: 3728kb

input:

1
500
169

output:

0 0

result:

ok 

Test #7:

score: 0
Accepted
time: 3ms
memory: 3544kb

input:

1099
900
200

output:

1 1

result:

ok 

Test #8:

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

input:

1100
900
200

output:

1 1

result:

ok 

Test #9:

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

input:

1101
900
200

output:

1 1

result:

ok 

Test #10:

score: 0
Accepted
time: 2ms
memory: 3732kb

input:

1795
900
220

output:

2 0

result:

ok 

Test #11:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

8584
11299
169

output:

0 51

result:

ok 

Test #12:

score: 0
Accepted
time: 3ms
memory: 3600kb

input:

85
4845
169

output:

0 1

result:

ok 

Test #13:

score: 0
Accepted
time: 2ms
memory: 3580kb

input:

87
7653
170

output:

0 1

result:

ok 

Test #14:

score: 0
Accepted
time: 2ms
memory: 3540kb

input:

170
6477
169

output:

0 1

result:

ok 

Test #15:

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

input:

172
8962
169

output:

0 1

result:

ok 

Test #16:

score: 0
Accepted
time: 2ms
memory: 3544kb

input:

431
500
169

output:

1 0

result:

ok 

Test #17:

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

input:

1344361
11299
220

output:

80 2002

result:

ok 

Test #18:

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

input:

2474261
11299
220

output:

38 9295

result:

ok 

Test #19:

score: 0
Accepted
time: 1ms
memory: 3548kb

input:

3514830
11220
220

output:

0 15976

result:

ok 

Test #20:

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

input:

115004670
11220
220

output:

0 522748

result:

ok 

Test #21:

score: 0
Accepted
time: 2ms
memory: 3668kb

input:

10
7013
212

output:

0 0

result:

ok 

Test #22:

score: 0
Accepted
time: 2ms
memory: 3732kb

input:

766
3734
209

output:

0 4

result:

ok 

Test #23:

score: 0
Accepted
time: 2ms
memory: 3732kb

input:

22162
6263
196

output:

0 113

result:

ok 

Test #24:

score: 0
Accepted
time: 2ms
memory: 3604kb

input:

8174031
7921
172

output:

123 41859

result:

ok 

Test #25:

score: 0
Accepted
time: 0ms
memory: 3684kb

input:

31647263
4029
184

output:

155 168602

result:

ok 

Test #26:

score: 0
Accepted
time: 3ms
memory: 3668kb

input:

361366292
10173
185

output:

64 1949812

result:

ok 

Test #27:

score: 0
Accepted
time: 4ms
memory: 3660kb

input:

977906491
8351
216

output:

101 4523440

result:

ok 

Test #28:

score: 0
Accepted
time: 26ms
memory: 3660kb

input:

999999983
502
172

output:

32 5813860

result:

ok 

Test #29:

score: 0
Accepted
time: 1ms
memory: 3604kb

input:

999999993
11296
218

output:

44 4584876

result:

ok 

Test #30:

score: 0
Accepted
time: 23ms
memory: 3600kb

input:

1000000000
500
169

output:

54 5917000

result:

ok 

Test #31:

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

input:

1000000000
11299
220

output:

60 4542373

result:

ok