QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#240022#5490. Smallest Calculated Valuekareemsakkary#AC ✓1ms3572kbC++141.7kb2023-11-05 08:01:532023-11-05 08:01:54

Judging History

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

  • [2023-11-05 08:01:54]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3572kb
  • [2023-11-05 08:01:53]
  • 提交

answer

#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define fr(n) for(ll i = 0 ; i < n ; i++)
#define frj(n) for(ll j = 0 ; j < n ; j++)
#define ll long long
#define files    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define Ksakkary ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const ll mod = 1e9 + 7;

using namespace std;


ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll mult(ll a, ll b) {
    return ((a % mod) * (b % mod)) % mod;
}

ll add(ll a, ll b) {
    return ((a % mod) + (b % mod)) % mod;
}

ll subtract(ll a, ll b) {
    return ((a % mod) - (b % mod) + (2 * mod)) % mod;
}

const unsigned ll N = 2e6 + 5;

int knightX[] = {-2, -2, 2, 2, 1, 1, -1, -1};
int knighty[] = {-1, 1, -1, 1, -2, 2, -2, 2};

int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};
int dy[] = {0, -1, 0, 1, -1, 1, -1, 1};
char di[] = {'D', 'L', 'U', 'R'};
int num[3];
int slv(int res , int ind){
    if(ind == 3) return res;
    int ret = 1e9;
    int x = slv(res+num[ind],ind+1);
    if(x >= 0)
        ret = min(ret, x);

    x = slv(res-num[ind],ind+1);
    if(x >= 0)
        ret = min(ret, x);

    x = slv(res*num[ind],ind+1);
    if(x >= 0)
        ret = min(ret, x);

    if(res % num[ind] == 0) {
        x = slv(res/num[ind],ind+1);
        if(x >= 0)
            ret = min(ret, x);
    }
    return ret;
}
void solve() {

    fr(3){
        cin >> num[i];
    }
    cout << slv(num[0] , 1);
}

int main() {
    Ksakkary
#ifndef ONLINE_JUDGE
    files
#endif
    // sieve();
    ll t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3344kb

input:

2 3 5

output:

0

result:

ok single line: '0'

Test #2:

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

input:

9 9 9

output:

0

result:

ok single line: '0'

Test #3:

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

input:

5 7 3

output:

1

result:

ok single line: '1'

Test #4:

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

input:

406 21 18

output:

367

result:

ok single line: '367'

Test #5:

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

input:

250 750 1000

output:

0

result:

ok single line: '0'

Test #6:

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

input:

774 261 747

output:

288

result:

ok single line: '288'

Test #7:

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

input:

893 407 5

output:

260

result:

ok single line: '260'

Test #8:

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

input:

949 949 595

output:

0

result:

ok single line: '0'

Test #9:

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

input:

52 10 474

output:

46

result:

ok single line: '46'

Test #10:

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

input:

730 10 913

output:

986

result:

ok single line: '986'

Test #11:

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

input:

700 40 250

output:

112

result:

ok single line: '112'

Test #12:

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

input:

808 360 28

output:

16

result:

ok single line: '16'

Test #13:

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

input:

936 2 31

output:

437

result:

ok single line: '437'

Test #14:

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

input:

900 3 5

output:

60

result:

ok single line: '60'

Test #15:

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

input:

1 1 1

output:

0

result:

ok single line: '0'

Test #16:

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

input:

1000 1 1

output:

998

result:

ok single line: '998'

Test #17:

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

input:

1 1000 1

output:

999

result:

ok single line: '999'

Test #18:

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

input:

1000 1000 1

output:

0

result:

ok single line: '0'

Test #19:

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

input:

1 1 1000

output:

0

result:

ok single line: '0'

Test #20:

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

input:

1000 1 1000

output:

0

result:

ok single line: '0'

Test #21:

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

input:

1 1000 1000

output:

0

result:

ok single line: '0'

Test #22:

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

input:

1000 1000 1000

output:

0

result:

ok single line: '0'

Test #23:

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

input:

497 773 206

output:

1064

result:

ok single line: '1064'

Test #24:

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

input:

592 446 188

output:

334

result:

ok single line: '334'

Test #25:

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

input:

935 401 173

output:

361

result:

ok single line: '361'

Test #26:

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

input:

326 747 928

output:

145

result:

ok single line: '145'

Test #27:

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

input:

129 905 221

output:

813

result:

ok single line: '813'

Test #28:

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

input:

522 227 296

output:

453

result:

ok single line: '453'

Test #29:

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

input:

447 699 94

output:

1052

result:

ok single line: '1052'

Test #30:

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

input:

903 846 435

output:

492

result:

ok single line: '492'

Test #31:

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

input:

526 651 138

output:

13

result:

ok single line: '13'

Test #32:

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

input:

387 317 879

output:

949

result:

ok single line: '949'

Test #33:

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

input:

1000 20 6

output:

44

result:

ok single line: '44'

Test #34:

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

input:

1000 11 10

output:

979

result:

ok single line: '979'