QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#21249 | #511. Difference | perspective | AC ✓ | 1225ms | 371412kb | C++20 | 750b | 2022-03-04 11:36:40 | 2022-05-08 02:47:14 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include<vector>
using namespace std;
const int MAX = 200000000;
const int MAXSTEPS = 10000;
short used[MAX] = {false};
int d = 1;
vector<int> vals;
int nvals = 0;
int main()
{
int start, target;
cin >> start >> target;
int count = 0;
while (count < MAXSTEPS) {
count++;
if (start < MAX)
used[start] = true;
for(int i=0; i<nvals; i++) {
if (start-vals[i] < MAX)
used[start - vals[i]] = true;
}
if (used[target])
break;
vals.push_back(start);
nvals++;
while (used[d])
d++;
start += d;
}
cout << count << endl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3580kb
input:
1 5
output:
4
result:
ok single line: '4'
Test #2:
score: 0
Accepted
time: 2ms
memory: 3592kb
input:
1 12
output:
4
result:
ok single line: '4'
Test #3:
score: 0
Accepted
time: 2ms
memory: 3660kb
input:
5 1
output:
2
result:
ok single line: '2'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3720kb
input:
1 1
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3724kb
input:
1 100
output:
42
result:
ok single line: '42'
Test #6:
score: 0
Accepted
time: 1042ms
memory: 371368kb
input:
1 39129
output:
10000
result:
ok single line: '10000'
Test #7:
score: 0
Accepted
time: 1068ms
memory: 371368kb
input:
1 99984544
output:
10000
result:
ok single line: '10000'
Test #8:
score: 0
Accepted
time: 1018ms
memory: 371412kb
input:
1 188286782
output:
10000
result:
ok single line: '10000'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
100 1
output:
2
result:
ok single line: '2'
Test #10:
score: 0
Accepted
time: 1ms
memory: 3560kb
input:
100 100
output:
1
result:
ok single line: '1'
Test #11:
score: 0
Accepted
time: 1027ms
memory: 367976kb
input:
100 38961
output:
10000
result:
ok single line: '10000'
Test #12:
score: 0
Accepted
time: 1122ms
memory: 367976kb
input:
100 99940474
output:
10000
result:
ok single line: '10000'
Test #13:
score: 0
Accepted
time: 1092ms
memory: 367880kb
input:
100 186474736
output:
10000
result:
ok single line: '10000'
Test #14:
score: 0
Accepted
time: 51ms
memory: 41488kb
input:
92 11942
output:
3390
result:
ok single line: '3390'
Test #15:
score: 0
Accepted
time: 2ms
memory: 3596kb
input:
10 12050
output:
170
result:
ok single line: '170'
Test #16:
score: 0
Accepted
time: 0ms
memory: 6504kb
input:
97 177304
output:
668
result:
ok single line: '668'
Test #17:
score: 0
Accepted
time: 56ms
memory: 47880kb
input:
55 2943751
output:
3653
result:
ok single line: '3653'
Test #18:
score: 0
Accepted
time: 10ms
memory: 16084kb
input:
64 4643557
output:
1932
result:
ok single line: '1932'
Test #19:
score: 0
Accepted
time: 29ms
memory: 30404kb
input:
20 13108321
output:
2861
result:
ok single line: '2861'
Test #20:
score: 0
Accepted
time: 135ms
memory: 68352kb
input:
95 4026722
output:
4391
result:
ok single line: '4391'
Test #21:
score: 0
Accepted
time: 2ms
memory: 10028kb
input:
77 3040555
output:
1407
result:
ok single line: '1407'
Test #22:
score: 0
Accepted
time: 183ms
memory: 91536kb
input:
4 3561761
output:
5030
result:
ok single line: '5030'
Test #23:
score: 0
Accepted
time: 684ms
memory: 255284kb
input:
38 122564001
output:
8354
result:
ok single line: '8354'
Test #24:
score: 0
Accepted
time: 699ms
memory: 253716kb
input:
95 89195320
output:
8396
result:
ok single line: '8396'
Test #25:
score: 0
Accepted
time: 1000ms
memory: 340796kb
input:
60 149297808
output:
9686
result:
ok single line: '9686'
Test #26:
score: 0
Accepted
time: 1042ms
memory: 346460kb
input:
65 19852042
output:
9732
result:
ok single line: '9732'
Test #27:
score: 0
Accepted
time: 1048ms
memory: 351668kb
input:
3 152881363
output:
9778
result:
ok single line: '9778'
Test #28:
score: 0
Accepted
time: 999ms
memory: 360336kb
input:
41 182614945
output:
9823
result:
ok single line: '9823'
Test #29:
score: 0
Accepted
time: 1225ms
memory: 355204kb
input:
27 110436294
output:
9872
result:
ok single line: '9872'
Test #30:
score: 0
Accepted
time: 1193ms
memory: 366772kb
input:
87 174372628
output:
9938
result:
ok single line: '9938'