Skip to content

Instantly share code, notes, and snippets.

@ichirin2501
ichirin2501 / srm460_div2_medium.cpp
Created September 4, 2011 00:37
srm460::div2::medium
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;
class TheFansAndMeetingsDivTwo{
public:
double find(vector <int> minJ, vector <int> maxJ, vector <int> minB, vector <int> maxB){
double ret = 0.0;
@ichirin2501
ichirin2501 / PE22.pl
Created August 13, 2012 15:59
Project Euler 22
#!perl -apnF','
$c++,s/[^"]/$s+=(ord($&)-64)*$c/eg for sort@F;
$_=$s;
@ichirin2501
ichirin2501 / PE23.pl
Created August 14, 2012 02:23
Project Euler 23
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use List::Util qw/sum/;
sub factor{
my $n = shift;
my %hash = ();
@ichirin2501
ichirin2501 / PE25.pl
Created August 16, 2012 12:20
Project Euler 25
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use bigint;
my ($a, $b, $idx) = (1, 1, 1);
while(1){
if( length($a) >= 1000 ){
@ichirin2501
ichirin2501 / PE26.pl
Created August 17, 2012 13:13
Project Euler 26
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my $ans = -1;
my $mx = 0;
for(2..999){
@ichirin2501
ichirin2501 / PE27.pl
Created August 18, 2012 06:40
Project Euler 27
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
sub is_prime{
my $n = shift;
return 0 if $n < 2;
@ichirin2501
ichirin2501 / PE28.pl
Created August 19, 2012 04:05
Project Euler 28
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use List::Util qw/sum/;
my $i;
my $res = 0;
for($i=1; $i<=999; $i+=2){
@ichirin2501
ichirin2501 / PE29.pl
Created August 20, 2012 04:45
Project Euler 29
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use bigint;
use List::MoreUtils qw/uniq/;
my ($a, $b) = (100, 100);
my @res = uniq map{ my $t = $_; map{ $t ** $_ } 2..$b } 2..$a;
@ichirin2501
ichirin2501 / PE30.pl
Created August 21, 2012 05:18
Project Euler 30
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use List::Util qw/sum/;
# (9^5) + (9^5) + (9^5) + (9^5) + (9^5) + (9^5) = 354294
my @res = grep{ my $t = $_; $t == sum map{$_ ** 5} split(//,$t) } 2..354294;
print sum @res;
@ichirin2501
ichirin2501 / PE31.pl
Created August 22, 2012 02:30
Project Euler 31
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
sub calc{
my $L = shift;
my @coin = $#_ == 0 ? @{$_[0]} : @_;