Submission #15986546
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl '\n'
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define F first
#define S second
void solve()
{
ll x,k,d;
cin>>x>>k>>d;
x=abs(x);
if((x/d)>=k)
{
ll y=x/d;
x-=k*d;
cout<<x<<endl;
}
else
{
ll y=x/d;
x=x-(y*d);
k=k-y;
if(k%2==0)
{
cout<<abs(x)<<endl;
}
else
{
cout<<min(abs(x+d),abs(x-d))<<endl;
}
}
}
int main()
{
// ios_base::sync_with_stdio(false);
// cin.tie(NULL);
int t;
t=1;
while(t--)
{
solve();
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Walking Takahashi |
| User | EramallaAravind |
| Language | C++ (GCC 9.2.1) |
| Score | 300 |
| Code Size | 617 Byte |
| Status | AC |
| Exec Time | 8 ms |
| Memory | 3568 KiB |
Compile Error
./Main.cpp: In function ‘void solve()’:
./Main.cpp:16:6: warning: unused variable ‘y’ [-Wunused-variable]
16 | ll y=x/d;
| ^
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | s1.txt, s2.txt, s3.txt, s4.txt |
| All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, s1.txt, s2.txt, s3.txt, s4.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01.txt | AC | 8 ms | 3448 KiB |
| 02.txt | AC | 2 ms | 3496 KiB |
| 03.txt | AC | 3 ms | 3508 KiB |
| 04.txt | AC | 3 ms | 3492 KiB |
| 05.txt | AC | 2 ms | 3568 KiB |
| 06.txt | AC | 2 ms | 3452 KiB |
| 07.txt | AC | 3 ms | 3364 KiB |
| 08.txt | AC | 2 ms | 3480 KiB |
| 09.txt | AC | 3 ms | 3476 KiB |
| 10.txt | AC | 2 ms | 3484 KiB |
| 11.txt | AC | 2 ms | 3504 KiB |
| 12.txt | AC | 2 ms | 3496 KiB |
| 13.txt | AC | 2 ms | 3448 KiB |
| 14.txt | AC | 2 ms | 3368 KiB |
| 15.txt | AC | 2 ms | 3332 KiB |
| 16.txt | AC | 2 ms | 3420 KiB |
| 17.txt | AC | 3 ms | 3452 KiB |
| 18.txt | AC | 3 ms | 3332 KiB |
| 19.txt | AC | 2 ms | 3460 KiB |
| 20.txt | AC | 2 ms | 3420 KiB |
| 21.txt | AC | 2 ms | 3496 KiB |
| 22.txt | AC | 4 ms | 3568 KiB |
| 23.txt | AC | 2 ms | 3452 KiB |
| 24.txt | AC | 2 ms | 3452 KiB |
| 25.txt | AC | 2 ms | 3500 KiB |
| 26.txt | AC | 2 ms | 3488 KiB |
| 27.txt | AC | 2 ms | 3396 KiB |
| s1.txt | AC | 2 ms | 3420 KiB |
| s2.txt | AC | 2 ms | 3508 KiB |
| s3.txt | AC | 2 ms | 3396 KiB |
| s4.txt | AC | 3 ms | 3484 KiB |