Created
August 20, 2012 04:59
-
-
Save kiyotune/3401081 to your computer and use it in GitHub Desktop.
Project Euler 問題29 その2
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
#!/usr/local/bin/octave -q | |
% parse arguments | |
_argv = argv(); | |
amin = str2num(char(_argv(1))); | |
amax = str2num(char(_argv(2))); | |
bmin = str2num(char(_argv(3))); | |
bmax = str2num(char(_argv(4))); | |
% calc | |
v = [amin:1:amax]'.^[amin:1:amax]; | |
v = sort(unique(v)); | |
ans = length(v); | |
% disp | |
printf("(%d<=a<=%d, %d<=b<=%d) Ans: %d\n", amin, amax, bmin, bmax, ans); | |
% <Answer> | |
% (2<=a<=100, 2<=b<=100) Ans: 9183 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
すんなりできた。