yukicoder No.966 - 引き算をして門松列(その1)

Source

ニコニコミュニティ
問題文

問題概要

省略

解法

省略

cLayversion 20200119-1)のコード

C++に変換後のコードはこちら

int solve(int a, int b, int c){
  ll res = 0;
  if(b >= c){
    res += b-c+1;
    b = c-1;
  }
  if(a >= b){
    res += a-b+1;
    a = b-1;
  }
  if(a <= 0) res = int_inf;
  return res;
}

{
  int A, B, C;
  int res;
  REP(rd_int()){
    res = int_inf;
    rd(A,B,C);
    res <?= solve(A,C,B);
    res <?= solve(B,A,C);
    res <?= solve(C,A,B);
    res <?= solve(B,C,A);
    wt(if[res==int_inf,-1,res]);
  }
}

Current time: 2024年04月26日09時18分08秒
Last modified: 2020年01月19日05時33分50秒 (by laycrs)
Tags: Competitive_Programming_Incomplete yukicoder
トップページに戻る

Logged in as: unknown user (not login)

ログイン: