2009-11-10から1日間の記事一覧

PKU 1008

PKU

Maya Calendar 月名をコピペするときにスペースが入ったせいで、Presentation Errorが出て悩んだ。 #include <iostream> #include <string> #include <algorithm> using namespace std; int main() { // month names of Haab string hmonth[19] = { "pop", "no", "zip", "zotz", "tzec", "</algorithm></string></iostream>…

PKU 1007

PKU

DNA Sorting #include <iostream> #include <vector> #include <algorithm> #include <string> using namespace std; bool cmp( string a, string b ); int sortedness( string s ); int main() { int n, m; cin >> n >> m; vector<string> dna(m); for ( int i=0; i<m; i++ ) cin >> dna[i]; sort( dna.begin(), dna.end(</m;></string></string></algorithm></vector></iostream>…

PKU 1006

PKU

Biorhythms #include <iostream> using namespace std; int main() { for ( int c=1; ; c++ ) { int p, e, i, d; cin >> p >> e >> i >> d; if ( p == -1 ) break; for ( int j=1; j<=21252; j++ ) { if ( ( j + d - p ) % 23 == 0 && ( j + d - e ) % 28 == 0 && ( j </iostream>…

PKU 1005

PKU

I Think I Need a Houseboat #include <iostream> #define _USE_MATH_DEFINES #include <math.h> using namespace std; int main() { int n; cin >> n; for ( int i=1; i<=n; i++ ) { double x, y; cin >> x >> y; double r = sqrt( x*x + y*y ); double area = M_PI/2 * r*r; </math.h></iostream>…

PKU 1004

PKU

Financial Management #include <stdio.h> int main() { double sum = 0; for ( int i=0; i<12; i++ ) { double m; scanf( "%lf", &m ); sum += m; } printf( "$%.2f\n", sum / 12 ); return 0; }</stdio.h>

PKU 1003

PKU

Hangover #include <iostream> using namespace std; int main() { double l; while ( cin>>l, l>0 ) { double d = 0; int n; for ( n=1; ; n++ ) { d += 1. / (n+1); if ( d > l ) break; } cout << n << " card(s)" << endl; } return 0; }</iostream>

PKU 1002

PKU

487-3279 #include <iostream> #include <string> #include <map> using namespace std; string normalize( string num ); int main() { int n; cin >> n; map<string,int> count; for ( int i=0; i<n; i++ ) { string num; cin >> num; string stand = normalize( num ); count[stand] += 1; } bool dup = false; for ( ma…</n;></string,int></map></string></iostream>

PKU 1001

PKU

Java('A`)ワカンネ Exponentiation import java.util.Scanner; import java.math.BigDecimal; class Main { public static void main( String[] args ) { Scanner s = new Scanner( System.in ); while ( s.hasNext() ) { String R = s.next(); int n = s.nextIn…

PKU 1000

PKU

A+B Problem #include <iostream> using namespace std; int main() { int a, b; cin >> a >> b; cout << a+b << endl; return 0; }</iostream>

PKU 1009

PKU

Edge Detection AとBの境目が画像の端にある場合も含めて、入力画像の値がA→Bと変化するときに出力画像の値が変わる可能性があるのは、下図の赤太線の部分のみ。 出力画像の値が変わる可能性がある場所で、RLEのブロックを分割。 分割したブロックそれぞれで…