Submission #1175421


Source Code Expand

#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};

signed main(){
    ll x, y;
    ll ans = 0;
    cin >> x >> y;
    
    if(x + y == 0){
        cout << 1;
        return 0;
    }
    
    if(x > y){
        x *= -1;
        ans++;
    }
    //cout << x << " " << y << endl;
    
    ll diffa  = min(abs(y - x), abs(abs(y) - x));
    ans += diffa;
    x += diffa;
    //cout << x << " " << y << endl;
    
    if(x !=  y) ans++;
    cout << ans;
}

Submission Info

Submission Time
Task A - Simple Calculator
User Noimin
Language C++14 (GCC 5.4.1)
Score 0
Code Size 964 Byte
Status WA
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 3
AC × 9
WA × 5
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt
Case Name Status Exec Time Memory
0_00.txt AC 1 ms 256 KB
0_01.txt AC 1 ms 256 KB
0_02.txt AC 1 ms 256 KB
1_00.txt AC 1 ms 256 KB
1_01.txt AC 1 ms 256 KB
1_02.txt WA 1 ms 256 KB
1_03.txt AC 1 ms 256 KB
1_04.txt AC 1 ms 256 KB
1_05.txt WA 1 ms 256 KB
1_06.txt WA 1 ms 256 KB
1_07.txt AC 1 ms 256 KB
1_08.txt WA 1 ms 256 KB
1_09.txt WA 1 ms 256 KB
1_10.txt AC 1 ms 256 KB