結果

問題 No.816 Beautiful tuples
ユーザー akakimidoriakakimidori
提出日時 2019-04-19 21:29:22
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 607 bytes
コンパイル時間 517 ms
コンパイル使用メモリ 28,876 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-23 23:24:58
合計ジャッジ時間 1,214 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))

void run (void) {
  i32 a, b;
  scanf ("%" SCNi32 "%" SCNi32, &a, &b);
  i32 x = MIN(a, b);
  i32 y = MAX(a, b);
  i32 c = y - x;
  if ((x + y) % c == 0 && (c + y) % x == 0) {
    printf ("%" PRIi32 "\n", c);
    return;
  }
  c = x + y;
  if (((i64) c + x) % y == 0 && ((i64) c + y) % x == 0) {
    printf ("%" PRIi32 "\n", c);
    return;
  }
  puts("-1");
}

int main (void) {
  run();
  return 0;
}
0