QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#275884#5259. Skills in PillswangqingxianWA 0ms3712kbC++141.2kb2023-12-05 11:00:102023-12-05 11:00:10

Judging History

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

  • [2023-12-05 11:00:10]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3712kb
  • [2023-12-05 11:00:10]
  • 提交

answer

#include<algorithm>
#include<vector>
#include<cstdio>
#include<map>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<iomanip>
#include<bitset>
#include<queue>
#include<cassert>
#include<stdlib.h>
#include<cmath>
#include<set>
//#define ll long long
#define ld long double
#define For(i,l,r) for(int i=(l);i<=(r);i++)
#define rof(i,r,l) for(int i=(r);i>=(l);i--)
#define db double
#define mem0(a) memset(a,0,sizeof(a))
#define ull unsigned long long
#define lowbit(t) (t&-t)
#define uint unsigned int
#define int long long
#define x1 alkjhfasdlkjfawlkf
#define x2 fsdouifiaojlfkwewj
#define y1 sdlkajfaskljfiowfw
#define y2 ajlfioueuoijwefoja
using namespace std;
const int N=1e6+10,inf=0x7fffffff,mod=998244353;
int k1,k2,n;
int dp[N];
int f(int x,int y){
    int i=min(x,y);
    if(x>n&&y>n)return 0;
    if(dp[i]>=0)return dp[i];
    if(x==y)return dp[i]=min(f(x-1+k1,y),f(x,y-1+k2))+1;
    int nx=(x<y)?x+k1:x,ny=(x>y)?y+k2:y;
    return f(nx,ny)+1;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin>>k1>>k2>>n;
    For(i,1,n)dp[i]=-1;
    cout<<f(k1,k2)<<endl;
    return 0;
}
/*
 */

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 9 20

output:

8

result:

ok single line: '8'

Test #2:

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

input:

8 2 12

output:

7

result:

ok single line: '7'

Test #3:

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

input:

2 5 15

output:

10

result:

ok single line: '10'

Test #4:

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

input:

10 8 13

output:

2

result:

ok single line: '2'

Test #5:

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

input:

6 6 19

output:

6

result:

ok single line: '6'

Test #6:

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

input:

2 3 5

output:

3

result:

ok single line: '3'

Test #7:

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

input:

4 2 8

output:

6

result:

ok single line: '6'

Test #8:

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

input:

5 5 5

output:

2

result:

ok single line: '2'

Test #9:

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

input:

3 8 11

output:

4

result:

ok single line: '4'

Test #10:

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

input:

5 8 16

output:

5

result:

ok single line: '5'

Test #11:

score: -100
Wrong Answer
time: 0ms
memory: 3592kb

input:

9 7 279

output:

71

result:

wrong answer 1st lines differ - expected: '70', found: '71'