結果

問題 No.1486 ロボット
ユーザー kappybarkappybar
提出日時 2021-04-29 14:57:43
言語 Go
(1.22.1)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 580 bytes
コンパイル時間 11,794 ms
コンパイル使用メモリ 212,196 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 23:38:04
合計ジャッジ時間 13,136 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 18 ms
4,380 KB
testcase_07 AC 18 ms
4,380 KB
testcase_08 AC 9 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 10 ms
4,380 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 4 ms
4,376 KB
testcase_17 AC 5 ms
4,376 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main
import "fmt"

func gcd(x int,y int) int {
  if y == 0 {
    return x
  } else {
    return gcd(y,x % y)
  }
}

func lcm(x int,y int) int {
  return x / gcd(x,y) * y
}

func main() {
  var (a int
       b int
       c int
       d int
       e int)
  fmt.Scan(&a,&b,&c,&d,&e)
  ab := a + b
  cd := c + d
  lc := lcm(ab,cd)
  reg := 0
  for i := 0 ;i < lc ; i++ {
    if (i % ab) < a && (i % cd) < c {
      reg ++
    }
  }
  ans := reg * (e / lc)
  e %= lc
  for i := 0 ;i < e ; i++ {
    if (i % ab) < a && (i % cd) < c {
      ans ++
    }
  }
  fmt.Println(ans)
}
0