Submission #19393032


Source Code Expand

Copy
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define ld long double

#define rep(i, n) for(int i = 0; i < n; ++i)
#define rep2(i, a, b) for(int i = a; i <= b; ++i)
#define rrep(i, a, b) for(int i = a; i >= b; --i)

#define pii pair<int, int>
#define pll pair<ll, ll>

#define fi first
#define se second

#define pb push_back
#define eb emplace_back

#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi(a,b,c,d) vector<vector<int>> a(b,vector<int>(c,d));
#define vvll(a,b,c,d) vector<vector<ll>> a(b,vector<ll>(c,d));

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define endl '\n'
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int MOD = 1000000007;
//const int MOD=998244353;
const ll INF = 1e18+1;
const int inf = 1e9+1;
const double PI = acos(-1);
int dx[8] = {1, 0, -1,  0,  1, 1, -1, -1};
int dy[8] = {0, 1,  0, -1, -1, 1,  1, -1};
bool range(int y, int x, int h, int w){
  if(y < 0 || x < 0 || y >= h || x >= w) return false;
  else return true;
}

const int MAX = 310000;


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  cout << fixed << setprecision(10);
  
  ll n, m;
  cin >> n >> m;
  
  if(m == 1) cout << 0 << endl;
  else{
    ll g = m-1;
    if(gcd(n, m) == 1) g = 1;
    ll bus = (n*g+m-1)/m;
    ll ans = bus*m-n*g;
    
    cout << ans << endl;
  }

  return 0;
}

Submission Info

Submission Time
Task D - Bus Tour
User cumin
Language C++ (GCC 9.2.1)
Score 0
Code Size 1764 Byte
Status WA
Exec Time 7 ms
Memory 3608 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 3
AC × 7
WA × 21
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_1.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_18.txt, subtask_1_19.txt, subtask_1_2.txt, subtask_1_20.txt, subtask_1_21.txt, subtask_1_22.txt, subtask_1_23.txt, subtask_1_24.txt, subtask_1_25.txt, subtask_1_3.txt, subtask_1_4.txt, subtask_1_5.txt, subtask_1_6.txt, subtask_1_7.txt, subtask_1_8.txt, subtask_1_9.txt
Case Name Status Exec Time Memory
sample_01.txt AC 6 ms 3540 KB
sample_02.txt AC 2 ms 3516 KB
sample_03.txt AC 2 ms 3556 KB
subtask_1_1.txt WA 3 ms 3496 KB
subtask_1_10.txt WA 2 ms 3544 KB
subtask_1_11.txt AC 2 ms 3556 KB
subtask_1_12.txt AC 2 ms 3488 KB
subtask_1_13.txt AC 2 ms 3500 KB
subtask_1_14.txt WA 2 ms 3516 KB
subtask_1_15.txt WA 2 ms 3564 KB
subtask_1_16.txt WA 2 ms 3492 KB
subtask_1_17.txt WA 3 ms 3504 KB
subtask_1_18.txt WA 2 ms 3568 KB
subtask_1_19.txt WA 2 ms 3584 KB
subtask_1_2.txt WA 2 ms 3608 KB
subtask_1_20.txt WA 2 ms 3544 KB
subtask_1_21.txt WA 3 ms 3444 KB
subtask_1_22.txt WA 3 ms 3544 KB
subtask_1_23.txt AC 3 ms 3512 KB
subtask_1_24.txt WA 7 ms 3568 KB
subtask_1_25.txt WA 4 ms 3556 KB
subtask_1_3.txt WA 2 ms 3580 KB
subtask_1_4.txt WA 2 ms 3504 KB
subtask_1_5.txt WA 2 ms 3556 KB
subtask_1_6.txt WA 3 ms 3540 KB
subtask_1_7.txt WA 2 ms 3572 KB
subtask_1_8.txt WA 3 ms 3464 KB
subtask_1_9.txt WA 2 ms 3488 KB