結果
問題 | No.928 軽減税率? |
ユーザー |
![]() |
提出日時 | 2020-11-03 12:11:45 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,851 bytes |
コンパイル時間 | 10,711 ms |
コンパイル使用メモリ | 218,444 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-22 08:47:24 |
合計ジャッジ時間 | 11,765 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 34 |
ソースコード
package mainimport ("bufio""fmt""os""sort""strconv")var sc = bufio.NewScanner(os.Stdin)var wr = bufio.NewWriter(os.Stdout)func out(x ...interface{}) {fmt.Fprintln(wr, x...)}func getI() int {sc.Scan()i, e := strconv.Atoi(sc.Text())if e != nil {panic(e)}return i}func getF() float64 {sc.Scan()i, e := strconv.ParseFloat(sc.Text(), 64)if e != nil {panic(e)}return i}func getInts(N int) []int {ret := make([]int, N)for i := 0; i < N; i++ {ret[i] = getI()}return ret}func getS() string {sc.Scan()return sc.Text()}// min, max, asub, absなど基本関数func max(a, b int) int {if a > b {return a}return b}func min(a, b int) int {if a < b {return a}return b}func asub(a, b int) int {if a > b {return a - b}return b - a}func abs(a int) int {if a >= 0 {return a}return -a}func lowerBound(a []int, x int) int {idx := sort.Search(len(a), func(i int) bool {return a[i] >= x})return idx}func upperBound(a []int, x int) int {idx := sort.Search(len(a), func(i int) bool {return a[i] > x})return idx}func main() {defer wr.Flush()sc.Split(bufio.ScanWords)sc.Buffer([]byte{}, 1000000)// this template is new version.// use getI(), getS(), getInts(), getF()P, Q, A := getI(), getI(), getI()l := 0r := int(1e9 + 1)for l+1 != r {m := (l + r) / 2x := ((100 + P) * m) / 100y := ((100+Q)*m)/100 + Aif x >= y {r = m} else {l = m}}cnt := 0for i := 1; i < 1000; i++ {x := ((100 + P) * i) / 100y := ((100+Q)*i)/100 + Aif x < y {cnt++}}s := max(1000, l-100000)e := min(1e9, l+100000)cnt += s - 1000for i := s; i <= e; i++ {x := ((100 + P) * i) / 100y := ((100+Q)*i)/100 + Aif x < y {cnt++} else {// out(i, x, y)}}out(cnt)}