CSES - Datatähti 2022 loppu - Results
Submission details
Task:Pallo
Sender:Anttono
Submission time:2022-01-22 13:25:41 +0200
Language:C++ (C++11)
Status:READY
Result:10
Feedback
groupverdictscore
#1ACCEPTED10
#20
#30
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2, 3details
#2--2, 3details
#3--3details

Code

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

int t;

int main()
{
    cin>>t;
    ll n,m,k;
    for(int i=0;i<t;i++)
    {
        cin>>n>>m>>k;
        ll r = 0;
        ll nc = 1;
        ll mc = 1;
        pair<ll,ll> pos = {1,1};
        for(ll j=1;j<=k;j++)
        {
            pos.first += nc;
            pos.second += mc;
            if(pos.first == 1 || pos.second == 1 || pos.first == n || pos.second == m)
            {
                r++;
                if(pos.first == 1 || pos.first == n)
                {
                    nc = -nc;
                }
                if(pos.second == 1 || pos.second == m)
                {
                    mc = -mc;
                }
            }
        }
        cout<<r<<'\n';
    }
}

Test details

Test 1

Group: 1, 2, 3

Verdict: ACCEPTED

input
100
10 5 76
9 8 78
8 6 49
3 3 94
...

correct output
25
19
15
47
8
...

user output
25
19
15
47
8
...
Truncated

Test 2

Group: 2, 3

Verdict:

input
1000
7 5 99033171167123849
6 8 472883555390027162
9 10 258937093512465880
10 6 691774305483997493
...

correct output
33011057055707949
148620545979722822
57541576336103529
199845910473154830
52151060432923288
...

user output
(empty)

Test 3

Group: 3

Verdict:

input
1000
816332614 86098803 33572721929...

correct output
4310587870
45982113074
1550250683
717639357
3282221941
...

user output
(empty)