This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <iostream> | |
#include <cstring> | |
#include <algorithm> | |
using namespace std; | |
struct Node{ | |
Node*left,*right; | |
int key,value,sum; // sum:左側の数の合計 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 3 エラー修正 | |
n = a `div` length xs | |
where | |
a = 10 | |
xs = [1,2,3,4,5] | |
-- 4. 空でないリストの最後の要素 | |
mylast1 list = list!!((length list) - 1) | |
mylast2 list = head (reverse list) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(print ((lambda (n) (+ 1 (* 10 n n) (floor (/ (+ (* 16 n n n) (* 26 n)) 3)))) 500)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 10^6 > 6 * 9^5 より 求める数は最大でも6桁である。 | |
(defun pow (x) (expt x 5)) ; 一つの桁に対して行なう処理 | |
(defun check (v) | |
(let ((sum 0) (x v)) | |
(while (> x 0) | |
(incf sum (pow (mod x 10))) | |
(setq x (truncate x 10))) | |
(= v sum))) ; ある数xが問題の条件を満たすか |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(let ((pat (make-array 402 :initial-element 0))) | |
(setf (aref pat 0) 1) | |
(dolist (coin '(1 2 5 10 20 50 100 200)) | |
(dotimes (i 201) | |
(incf (aref pat (+ i coin)) (aref pat i)))) | |
(print (aref pat 200))) | |
; 73682 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(setq used (make-array 9 :initial-element t) | |
answer () | |
permutation (make-array 9)) | |
(defun number (l r) | |
(do ((i l (1+ i)) (ret 0)) ((= i r) ret) | |
(setq ret (+ (* ret 10) (aref permutation i))))) | |
(defun doIt () | |
(do ((r 2 (1+ r))) ((= r 9)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(let ((answer 1)) | |
(dotimes (a 90) | |
(dotimes (b 90) | |
(let ((x (+ a 10)) (y (+ b 10))) | |
(if (and (< x y) (not (= (mod x 10) 0)) (not (= (mod y 10) 0))) | |
(if (or (and (= (truncate y 10) (mod x 10)) (= (/ x y) (/ (truncate x 10) (mod y 10)))) | |
(and (= (truncate x 10) (mod y 10)) (= (/ x y) (/ (mod x 10) (truncate y 10))))) | |
(setq answer (* answer (/ x y)))))))) | |
(print (denominator answer))) | |
; => 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'FreeBasic | |
Public Function Rotate(ByVal x As Integer) As Integer | |
Dim s As String = Str(x) | |
Return Int(Val(Mid(s,2,Len(s)-1) + Mid(s,1,1))) | |
End Function | |
Dim Shared isPrime(1000000) As Integer, Used(1000000) As Integer, Answer As Integer = 0 | |
For i As Integer = 0 To 1000000 | |
isPrime(i)=1 | |
Used(i)=0 | |
Next |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <list> | |
#include <map> | |
#include <set> | |
#include <deque> | |
#include <stack> | |
#include <bitset> | |
#include <algorithm> | |
#include <functional> | |
#include <numeric> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ans=0; | |
var primes=Array(1,1,1,1,2,3,5,7,11,13,17) | |
function dfs(k, bit, sum) { | |
if((sum % 1000) % primes[k] != 0)return; | |
if(k == 10){ | |
ans += sum; | |
}else{ | |
for(var i = 0; i < 10; i++){ | |
if((bit >> i) &1)continue; | |
dfs(k + 1, bit | (1<<i), sum * 10 + i); |
OlderNewer