2011-09-01から1ヶ月間の記事一覧
3069 結局蟻本 #include <cstdio> #include <algorithm> using namespace std; int main() { int R, n; while (scanf("%d%d", &R, &n)) { if (R == -1 && n == -1) break; int army[n]; for (int i=0; i</algorithm></cstdio>
0085 漸化式自分では導けないorz #include <cstdio> int dfs(int n, int k) { if (n == 1) return 0; return (dfs(n-1,k)+k)%n; } int main() { int n, m; while (scanf("%d%d", &n, &m)) { if (n == 0 && m == 0) break; printf("%d\n", dfs(n,m)+1); } }</cstdio>
1050 意外と単純なdpだったよ。オーダー見積もりを鍛えなきゃとか思った。 #include <cstdio> #include <climits> #include <algorithm> using namespace std; int main() { int N; scanf("%d",&N); int map[N][N]; for (int i=0; i</algorithm></climits></cstdio>
後もう少しで予選。なぜかCしか通してない。smallの回答。 O(n^2)ぐらいです #include <cstdio> // O(n^2)? int solve(int r, int k, int n, int g[]) { int res = 0, npos = 0; for (int i=0; i</cstdio>
PKU 2559 ヒストグラムの最大長方形を求める問題。 スタックで左端のアドレスと縦の長さを管理して求めます。1964のついでに最大長方形の求め方を学ぶために通すつもりだったのですが、なぜか通らなかったので最終的に参考サイトのコードうつしました。 コメ…
class MineField { public: vector <string> getMineField( string mineLocations ) { vector<string> map; for (int i=0; i<9; i++) map.push_back("000000000"); for (int i=0; i</string></string>
UAPC2011Summer - A #include <cstdio> #include <iostream> #include <vector> #include <climits> using namespace std; typedef vector<int> vi; struct ch { string name; vector<int> time; int pt; ch() { pt=0; } }; int main() { int n, m, d; while (scanf("%d",&n)&&n!=0) { vi times(31, 0); ch</int></int></climits></vector></iostream></cstdio>…
class DigitsSum { public: int lastDigit( int n ) { if (n < 10) return n; int res = 0; stringstream ss; ss << n; string snum; ss >> snum; for (int i=0; i
1656 やるだけ #include <cstdio> #include <cstring> int board[100][100]; void fill(int x, int y, int L, int c) { for (int i=y; i</cstring></cstdio>
NumberofFiboCalls 単純BP class NumberofFiboCalls { public: vi dp1, dp0; void init() { dp0[0] = 1; dp1[1] = 1; for (int i=2; i<41; i++) { dp0[i] = dp0[i-1] + dp0[i-2]; dp1[i] = dp1[i-1] + dp1[i-2]; } } vector <int> fiboCallsMade( int n ) { vi re</int>…
0+0+0=0 936->824 最悪。。。 復讐コード載せます。
ReversedSum 今日のするめの直前にやったやつ めんどい class ReversedSum { public: int toInt(string st) { stringstream ss; ss.str(st); int res; ss >> res; return res; } string toStr(int num) { stringstream ss; ss << num; return ss.str(); } in…
2385 記憶喪失 #include <cstdio> int main() { int T, W; scanf("%d%d", &T, &W); int tree[T]; for (int i=0; i</cstdio>
結果発表 326st oxx +0/-0 203.68 888 -> 936(Highest)
MagicalSource やるだけ class MagicalSource { public: long long calculate( long long x ) { ll res = x; ll n = 0; for (int i=0; i<=12; i++) { n += (ll)pow(10, (double)i); if (x % n == 0) { res = x / n; } } return res; } };
2503 Trie木の練習のため、他人のコードをほぼてコピ。いや、木のところだけ。 struct trie{ trie *next[26]; char *val; trie() {for(int i=0; i<26; i++) next[i]=(trie*)0; val=(char*)0;} }; trie start; void add_node(char str[], char value[]) { tri…
(さぁGoogle検索の公式ホームページの次にこれが出てくるぐらいに内容の充実した文化祭紹介とでもしようかな。。。)というわけでこんにちわ。140周年というまさかの節目の開成祭の季節がやって来ました(つまり十年後は150周年・・・その年が羨ましい・・…
FoxMakingDice NとKの大小関係で場合分けする。 その上で、3つ以上N以下の数字二つでその数を作れる場合の数を計算していく。 class FoxMakingDice { public: long long theCount( int N, int K ) { ll res = 0; if (N < 6) return res; if (N >= K) { for (…
3425 構造体使って初めて通した。 できる問題のはばが広がった気がする。 #include <cstdio> #include <map> using namespace std; struct ac { int anum, cost; }; int main() { int N; int q, a, x; map<int, ac> m; scanf("%d",&N); for (int i=0; i</int,></map></cstdio>
Cとか変態だったから一応これだけやっといた。 また今度C以外の他の問題も暇だったら練習としてやる。 A やるだけ #include <cstdio> #include <algorithm> using namespace std; int main() { char input[300]; scanf("%s",input); int k=0,u=0,p=0,c=0; for (int i=0; i</algorithm></cstdio>
0118 #include <iostream> #include <vector> using namespace std; typedef vector<string> vs; int dx[] = {0,0,1,-1}; int dy[] = {-1,1,0,0}; int H, W; vs dfs(vs map, int ny, int nx, char now) { map[ny][nx] = '-'; for (int i=0; i<4; i++) { if (ny+dy[i]>=0&&ny+dy[i]<H&& nx+dx[i]>=0&&n</h&&></string></vector></iostream>…
bloggerの管理UIが新しくなりました。これが管理TOPとなります。非常に使いやすいです。ブログの書き込み画面も、かっこいいし。いいですね♪さてさて、ここからは余談ですが、先日Unityの参考書、通称ウニ本をAmazonで購入しましてまもなく付く予定なのです…
0173 #include <cstdio> #include <iostream> using namespace std; int main() { string c; int am, pm; while (cin >> c) { scanf("%d%d",&am,&pm); int resp = am + pm; int price = am * 200 + pm * 300; cout << c; printf(" %d %d\n", resp, price); } } 0174 #include <iostream> </iostream></iostream></cstdio>…
0044 #include <cstdio> #include <algorithm> using namespace std; int main() { int n; bool isprime[70001]; int prime[35000]; int pnum = 0; fill(isprime, isprime+70001, true); isprime[0] = isprime[1] = false; for (int i=2; i<70001; i++) { if (isprime[i]) { for</algorithm></cstdio>…
0077 #include <iostream> using namespace std; int main() { string str; while (cin >> str) { string res = ""; for (int i=0; i</iostream>
先輩にアドバイスいただいたので即実行。 まだ1ACしかしてないけど・・・
今日はひたすらAOJでPCKの過去問を解きまくって13時にはみんなが競争してたからJROに参加してちゃっかり一位を取ってきた。。。 解きまくったって言っても5問だけど。 ってか入力ムズい問題はダメだと思う。