結果
| 問題 |
No.3156 Count That Day's N
|
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2025-06-25 02:44:21 |
| 言語 | Scheme (Gauche-0.9.15) |
| 結果 |
AC
|
| 実行時間 | 836 ms / 3,000 ms |
| コード長 | 2,481 bytes |
| コンパイル時間 | 236 ms |
| コンパイル使用メモリ | 7,968 KB |
| 実行使用メモリ | 30,156 KB |
| 最終ジャッジ日時 | 2025-06-25 02:44:43 |
| 合計ジャッジ時間 | 22,087 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
ソースコード
(use scheme.list)
(use util.match)
(use srfi.13) ; string
(use srfi.42) ; list-ec
(use srfi.197) ; chain
(use gauche.collection)
(use gauche.generator)
(define input read-line)
(define (ii)
(string->number (read-line)))
(define (li)
(let ((s (read-line)))
(map string->number (string-split s " "))))
(define (prn . args)
(for-each (lambda (i x)
(when (> i 0)
(display " "))
(display x))
(iota (length args))
args)
(newline))
(define int string->number)
(define-method min ((xs <sequence>))
(apply min xs))
(define-method max ((xs <sequence>))
(apply max xs))
(define (minmax . xs)
(values->list (apply min&max xs)))
(define-method minmax ((xs <sequence>))
(values->list (apply min&max xs)))
(define (sum xs) (apply + xs))
(define (divmod a b)
(values->list (div-and-mod a b)))
(define (1+ n) (+ n 1))
(define (1- n) (- n 1))
(define (!= a b) (not (= a b)))
(define pow
(case-lambda
((a b) (expt a b))
((a b m) (expt-mod a b m))))
(define-method frequencies ((xs <sequence>))
(rlet1 ht (make-hash-table)
(for-each (^x (hash-table-update! ht x 1+ 0))
xs)))
(define (yn b)
(prn (if b "Yes" "No")))
(define-macro (input! bindings . body)
(let loop ((bs (reverse bindings))
(res '()))
(if (null? bs)
`(let*-values ,res
,@body)
(cond
((symbol? (car bs))
(loop (cdr bs)
(cons `((,(car bs)) (values (ii)))
res)))
((list? (car bs))
(loop (cdr bs)
(cons `(,(car bs) (apply values (li)))
res)))
(else
'error)))))
#;
(define-macro (clet1 pat expr . body)
`(receive ,pat (apply values ,expr)
,@body))
(define mlet1 match-let1)
(define isqrt exact-integer-sqrt)
(input! ((K N))
(let ((x6-list (list-ec (:while (: i 1 N) (<= (pow i 6) N))
(pow i 6)))
(x4-list (list-ec (:while (: i 1 N) (<= (pow i 4) N))
(pow i 4))))
(let ((ht (make-hash-table)))
(do-ec (:list x6 x6-list)
(:list x4 x4-list)
(:let x (+ x6 x4))
(if (<= x N))
(mlet1 (d m) (divmod x K)
(when (= m 0)
(let ((z (isqrt d)))
(when (= d (* z z))
(hash-table-put! ht x #t))))))
(prn (hash-table-size ht)))))
norioc