特に注意がない場合はM=1,000,000,007でMODを取ってください。 TLEは2sec
答えはありません. ときどき筆者も解けるかどうかわかっていない問題があります.
Mは素数とは限らないことに注意せよ.
- 0.1 aのb乗mod Mをもとめよ(a,b< 10^18, M < 10^9)
| import javax.imageio.*; | |
| import javax.imageio.stream.ImageOutputStream; | |
| import java.awt.image.BufferedImage; | |
| import java.io.File; | |
| import java.io.IOException; | |
| public class GifWriter { | |
| ImageWriter iw = ImageIO.getImageWritersByFormatName("gif").next(); | |
| BufferedImage buffer; | |
| boolean finish = false; |
| import clang.cindex | |
| from clang.cindex import Index | |
| def gen_stream_operator(cur): | |
| if cur.kind.name == "STRUCT_DECL": | |
| print("std::ostream& operator<<(std::ostream& os, const %s& rhs) {" % cur.displayname) | |
| for child in cur.get_children(): | |
| if child.kind.name == "FIELD_DECL": | |
| print(' os << "{member}:" << rhs.{member} << std::endl;'.format(member=child.displayname)) |
| ; $ sbcl --load a.cl --eval '(sb-ext:save-lisp-and-die "a.out" :toplevel #'\''main :executable t)' && time ( echo 100000000 | ./a.out > /dev/null ) | |
| ; ( echo 100000000 | ./a.out > /dev/null; ) 10.75s user 0.15s system 99% cpu 10.931 total | |
| ; $ sbcl --version | |
| ; SBCL 1.2.6 | |
| (defun main () | |
| (declare (optimize (speed 3) (debug 0) (safety 0) (compilation-speed 0))) | |
| (let* ((n (1+ (the fixnum (read)))) | |
| (is-prime (make-array n :element-type 'boolean :initial-element t))) |