PKU

POJ 1005 I Think I Need a Houseboat

1005 -- I Think I Need a Houseboat #include <cstdio> #include <cmath> int main() { int N; const double pi = 3.1415; scanf("%d\n", &N); for(int i = 0; i < N; i++){ double X, Y; scanf("%lf %lf\n", &X, &Y); double a = sqrt(X*X + Y*Y); for(int j = 0; ; j++){</cmath></cstdio>…

PKU 3253 Fence Repair

3253 -- Fence Repairなんか理解に少し時間を要したけど簡単な事だった。 要求された中で最も短い板2つを足して、コストに加算 それらの長さを足して1枚の板とする その1枚の長い板と、その他の板の中から、また再び最も短い板2つを足して…(以下続く) なんだ…

PKU 2431 Expedition

2431 -- Expedition #include <cstdio> #include <vector> #include <queue> #include <algorithm> using namespace std; int main() { int N; vector<pair<int, int> > v; scanf("%d\n", &N); for(int i = 0; i < N; i++){ int x, y; scanf("%d %d\n", &x, &y); v.push_back(make_pair(x, y)); } int L, P; sc</pair<int,></algorithm></queue></vector></cstdio>…

PKU 3069 Saruman's Army

3069 -- Saruman's Army情報オリンピックだって近いのに僕はこんな程度で大丈夫なんだろうか。 いや、全然大丈夫じゃないんだが。あと半月程度でどこまで伸びられるかが勝負だけれどもそんなに急に伸びる物とも思えんしなぁ… #include <cstdio> #include <vector> #include <algorithm> </algorithm></vector></cstdio>…

PKU 3617 Best Cow Line

3617 -- Best Cow Line #include <iostream> #include <string> #include <algorithm> using namespace std; int main(){ int N; cin>>N; string s; for(int i = 0; i < N; i++){ char c; cin>>c;s += c; } string t, u; while(!s.empty()){ u = s; reverse(u.begin(), u.end()); if(u > s</algorithm></string></iostream>…

PKU 2386 Lake Counting

2386 -- Lake Countingアリ本もう一冊手に入れたので読み進めていく事にした。 #include <iostream> #include <vector> #include <string> using namespace std; bool inline validate(int x, int y, vector<string>& v){ return (0 <= x) && (x < v.size()) && (0 <= y) && (y < v[0].size());</string></string></vector></iostream>…

PKU 1051 P,MTHBGWB

1051 -- P,MTHBGWBモールス信号。 #include <iostream> #include <string> #include <map> #include <algorithm> using namespace std; inline void maketable(map<char, string>& enc, map<string, char>& dec){ const char *abc[] = { ".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-", ".-..","--","</string,></char,></algorithm></map></string></iostream>…

PKU 1068 Parencodings

1068 -- Parencodings #include <cstdio> #include <string> using namespace std; int main() { int t; scanf("%d\n", &t); for(int i = 0; i < t; i++){ int n; scanf("%d\n", &n); string s; for(int j = 0,lm = 0, m; j < n; j++){ scanf("%d", &m); s += string(m - lm,</string></cstdio>…

PKU 1012 Joseph

1012 -- Joseph #include <cstdio> int main() { int k , _n; int r[14]; for(int i = 0; i < 14; i++) r[i] = 0; while(scanf("%d", &k), k){ if(!r[k]){ _n = k * 2; for(int i = k; ; i++){ int n = _n, p = 0; while(n != k){ p = (p + i) % n--; if(p < k) goto</cstdio>…

PKU 1008 Maya Calendar

#include <cstdio> #include <cstring> int main(){ const char *haabmonths[] = {"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu", "uayet"}; char haabmon[7]; int haabday, </cstring></cstdio>…

POJ 2027 No Brainer (82 bytes)

main(x,y){for(gets(&x);scanf("%d%d",&x,&y)+1;)puts(x

PKU 1007 DNA Sorting

#include <vector> #include <string> #include <iostream> #include <algorithm> using namespace std; class dna { public: string seq; int unsortedness; int getuns(){ unsortedness = 0; for(int i = 0, l = seq.size() - 1; i < l; i++){ for(int j = i + 1, m = l + 1; j < m; j++){ if(se</algorithm></iostream></string></vector>…

PKU 1003 Hangover

#include <iostream> using namespace std; int main(){ while(1){ double n; cin>>n; if(n == 0) break; for(int i = 1; ; i++){ n -= (double)1 / (double)(i + 1); if(n <= 0){ cout<</iostream>

PKU 1026(途中)

またもやTime Limit Exceeded。 #include <cstdio> using namespace std; int main(){ char *src, *dst; int i, j, k, *key, keylen; scanf("%u\n", &keylen); key = new int[keylen]; for(i = 0; i < keylen; i++){ scanf("%u[ \n]", &key[i]); key[i]--; } src = n</cstdio>…

PKU 1026(途中)

Time Limit Exceededされたコード。 #include <iostream> #include <vector> #include <string> using namespace std; int main(){ vector<int> key; int i, j, keylen, tmp; cin>>keylen; for(i = 0; i < keylen; i++){ cin>>tmp; tmp--; key.push_back(tmp); } while(1){ tmp = 0; vector<char> </char></int></string></vector></iostream>…

PKU 1028

#include <stack> #include <string> #include <iostream> using namespace std; int main(){ string s, c ("http://www.acm.org/"); stack<string> f,b; while(1){ cin>>s; if(s == "QUIT") break; if(s == "BACK"){ if(b.empty()){ cout<<"Ignored\n"; continue; } f.push(c); c = b.top(); </string></iostream></string></stack>…

PKU 1006

#include <iostream> int main(){ using namespace std; int p,q,r,o; for(int c=1;;c++){ cin>>p>>q>>r>>o; if(p==-1)break; for(int i=1;i<21253;i++){ if(!((i+o-p)%23)&&!((i+o-q)%28)&&!((i+o-r)%33)){ cout<<"Case "<</iostream>

PKU 1003

結局また答え見ちゃった感じ。なので忘れた頃にもう一度自分で書いてsubmitしようと思う。 柔軟な発想 最短コード88B - Cozy Ozy これなんか見てると、アルゴリズマーになるにはやっぱりこういう柔軟な発想が必要なんだよなー、と思ってへこむ。 いや、柔軟…

PKU 1001

Javaに逃げた。その上にカンニングした。なんか全然といた気がしないけどいいや。そのうち時間ある時にC++かなんかで解こう。 import java.util.*; import java.math.*; public class Main { public static void main(String[] args){ for(Scanner s = new S…

PKU 1002

風邪なおった。 #include <iostream> #include <map> #include <string> int main(){ using namespace std; int i, j, c, sz, n; string s; char r[9]; map<string, int> m; cin>>n; for(i=0;i<n;i++){ c=0; cin>>s; for(j=0,sz=s.size();j</n;i++){></string,></string></map></iostream>

PKUに登録してみた

ゴールデンウィークなのに風邪ひいてぶったおれました。辛いしなんか悔しいです。それはそうとPKU JudgeOnlineに登録してみました。User -- peryaudoあとSICPは原文で読もうとか思ったまま停滞してます。英語力ホントにほしいですね。