QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#89267#5259. Skills in PillsCCSU_LRFWA 2ms3524kbC++141.0kb2023-03-19 14:39:282023-03-19 14:39:50

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-19 14:39:50]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3524kb
  • [2023-03-19 14:39:28]
  • 提交

answer


#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll lcm1,lcm2,lcm3;
ll lcm(ll a,ll b){
    return a/__gcd(a,b)*b;
}
struct node{
    int a,b,c;
};
ll n,m,k;
int check(ll b,ll c){
    if(lcm1 >= lcm2) c--;
    else b --;
    c = max(0ll,c);
    b = max(0ll,b);
    //return lcm1*b+lcm2*c+lcm(n,m)+min(lcm2,lcm1);
    if(lcm1*b+lcm2*c+lcm3+max(lcm2,lcm1) > k) return 1;
    else return 0;
}
int main()
{
    cin>>n>>m>>k;
    if(n==m) {
        cout<<k/n+(k+1)/n<<'\n';
        return 0;
    }
    lcm1 = lcm(n-1,m);
    lcm2 = lcm(n,m-1);
    lcm3 = lcm(n,m);
    ll ans = 0x3f3f3f3f;
    int ix ,ixx;
    for(int i = 0;i<=k/2;i++){
        ll l = 0,r =k/2;
        while(l<r){
            ll c = (l+r)>>1;
            if(check(i,c)) r = c;
            else l = c+1;
           // cout<<l<<" "<<r<<" "<<check(i,c)<<'\n';
        }
        //cout<<l<<'\n';
        if((i+k)/n+(l+k)/m < ans){
            ans = (i+k)/n+(l+k)/m;
        }
    }
    cout<<ans ;

    return 0;
}

详细

Test #1:

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

input:

3 9 20

output:

8

result:

ok single line: '8'

Test #2:

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

input:

8 2 12

output:

7

result:

ok single line: '7'

Test #3:

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

input:

2 5 15

output:

10

result:

ok single line: '10'

Test #4:

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

input:

10 8 13

output:

2

result:

ok single line: '2'

Test #5:

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

input:

6 6 19

output:

6

result:

ok single line: '6'

Test #6:

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

input:

2 3 5

output:

3

result:

ok single line: '3'

Test #7:

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

input:

4 2 8

output:

6

result:

ok single line: '6'

Test #8:

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

input:

5 5 5

output:

2

result:

ok single line: '2'

Test #9:

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

input:

3 8 11

output:

4

result:

ok single line: '4'

Test #10:

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

input:

5 8 16

output:

5

result:

ok single line: '5'

Test #11:

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

input:

9 7 279

output:

70

result:

ok single line: '70'

Test #12:

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

input:

8 3 56

output:

25

result:

ok single line: '25'

Test #13:

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

input:

5 9 46

output:

14

result:

ok single line: '14'

Test #14:

score: -100
Wrong Answer
time: 1ms
memory: 3228kb

input:

8 4 251

output:

94

result:

wrong answer 1st lines differ - expected: '93', found: '94'