結果
| 問題 | No.3156 Count That Day's N | 
| コンテスト | |
| ユーザー |  norioc | 
| 提出日時 | 2025-06-25 02:34:06 | 
| 言語 | Scheme (Gauche-0.9.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 855 ms / 3,000 ms | 
| コード長 | 2,466 bytes | 
| コンパイル時間 | 330 ms | 
| コンパイル使用メモリ | 8,232 KB | 
| 実行使用メモリ | 30,136 KB | 
| 最終ジャッジ日時 | 2025-06-25 02:34:29 | 
| 合計ジャッジ時間 | 22,679 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| 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)
(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)))
      (dolist (x6 x6-list)
        (dolist (x4 x4-list)
          (when (<= (+ x6 x4) N)
            (let ((x (+ x6 x4)))
              (mlet1 (d m) (divmod x K)
                (when (= m 0)
                  (let ((z (exact-integer-sqrt d)))
                    (when (= d (* z z))
                      (hash-table-put! ht x #t)))))))))
      (prn (hash-table-size ht)))))
            
            
            
        