QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#401165#5154. ETAucup-team1716#TL 0ms3624kbC++201.3kb2024-04-28 03:42:192024-04-28 03:42:21

Judging History

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

  • [2024-04-28 03:42:21]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3624kb
  • [2024-04-28 03:42:19]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;

int main()
{
    ll a, b;
    cin >> a;
    getchar();
    cin >> b;

    ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

    if(a<=b)
    {
        if(a==b) cout << "3 2\n1 2\n2 3";
        else if(a+1==b)
        {
            cout << b << " " << a << '\n';
            for(int i=1; i<=a; i++) cout << 1 << " " << i + 1 << "\n";
        }
        else cout << "impossible";
    }
    else
    {
        ll sum = 0, cnt = 1;
        vector<int> ans;

        for(int i=1; i<=a/b + 1; i++)
        {
            ans.pb(i);
            sum += i;
            cnt++;
        }

        /*cout << sum << " " << cnt;
        exit(0);*/

        while(a * cnt != b * sum)
        {
            //cout << a * cnt << " " << b * sum << "\n";
            if(a * cnt > b * sum)
            {
                ans.pb(a/b + 1);
                sum += a/b + 1;
                cnt++;
            }
            else
            {
                ans.pb(1);
                sum++;
                cnt++;
            }
        }

        cout << cnt << " " << cnt - 1 << "\n";
        for(int i=1; i<=cnt-1; i++)
        {
            cout << ans[i-1] << " " << i + 1 << "\n";
        }
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1/2

output:

2 1
1 2

result:

ok 

Test #2:

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

input:

1/3

output:

impossible

result:

ok 

Test #3:

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

input:

7/4

output:

12 11
1 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9
2 10
2 11
2 12

result:

ok 

Test #4:

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

input:

974/975

output:

975 974
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61
...

result:

ok 

Test #5:

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

input:

943/346

output:

692 691
1 2
2 3
3 4
3 5
3 6
3 7
3 8
3 9
3 10
3 11
3 12
3 13
3 14
3 15
3 16
3 17
3 18
3 19
3 20
3 21
3 22
1 23
3 24
3 25
3 26
3 27
3 28
3 29
3 30
1 31
3 32
3 33
3 34
3 35
3 36
3 37
1 38
3 39
3 40
3 41
3 42
3 43
3 44
1 45
3 46
3 47
3 48
3 49
3 50
3 51
1 52
3 53
3 54
3 55
3 56
3 57
3 58
3 59
1 60
3 61
...

result:

ok 

Test #6:

score: -100
Time Limit Exceeded

input:

912/7

output:


result: