This file contains hidden or 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
| from math import * | |
| t = input() | |
| for _ in range(t): | |
| a, b = map(int, raw_input().split()) | |
| a = ceil(sqrt(a)) | |
| b = floor(sqrt(b)) | |
| print int(b-a) + 1 |
This file contains hidden or 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
| private static long factorial(long n) { | |
| long accu = 1; | |
| for (long i = 1; i <= n; i++) { | |
| accu *= i; | |
| } | |
| return accu; | |
| } |
This file contains hidden or 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
| {-# LANGUAGE BangPatterns #-} | |
| {-# LANGUAGE ExistentialQuantification #-} | |
| {-# LANGUAGE FlexibleContexts #-} | |
| {-# LANGUAGE ForeignFunctionInterface #-} | |
| {-# LANGUAGE MagicHash #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| module Main (main) where | |
| import Foreign | |
| import Foreign.C.Types |
This file contains hidden or 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
| function getRandomIntInclusive(min, max) { | |
| min = Math.ceil(min); | |
| max = Math.floor(max); | |
| // both min and max are inclusive | |
| return Math.floor(Math.random() * (max - min + 1)) + min; | |
| } |
This file contains hidden or 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
| function getRandomInt(min, max) { | |
| min = Math.ceil(min); | |
| max = Math.floor(max); | |
| // min is inclusive, max is exclusive | |
| return Math.floor(Math.random() * (max - min)) + min; | |
| } |
This file contains hidden or 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
| function randomColor() { | |
| return '#'+Math.floor(Math.random()*16777215).toString(16); | |
| } |
This file contains hidden or 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
| for (var i = 0; i < 500; i += 13) { | |
| for (var j = 13; j < 480; j += 15) { | |
| context.fillStyle = randomColor(); | |
| context.fillText(makeMonster(),i,j); | |
| } | |
| } |
This file contains hidden or 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
| import scala.util.Random | |
| case class Point(x: Int, y: Int) | |
| def hilbert(n: Int, d: Int): Point = { | |
| var rx = 0 | |
| var ry = 0 | |
| var s = 1 | |
| var t = d | |
| var p = Point(0, 0) |
This file contains hidden or 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
| user=> (declare subst-in-s-exp) | |
| #'user/subst-in-s-exp | |
| user=> (defn subst | |
| #_=> [new old slist] | |
| #_=> (if (empty? slist) () | |
| #_=> (cons | |
| #_=> (subst-in-s-exp new old (first slist)) | |
| #_=> (subst new old (rest slist))))) | |
| #'user/subst | |
| user=> (defn subst-in-s-exp |
This file contains hidden or 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
| (defn list-length | |
| [xs] | |
| (if (empty? xs) 0 | |
| (+ 1 (list-length (rest xs))))) | |
| (defn list-length2 | |
| [xs] | |
| (loop [cnt 0 lst xs] | |
| (if (empty? lst) cnt | |
| (recur (+ 1 cnt)(rest lst))))) |
NewerOlder