C++競プロ学習日記(仮)

( 学習記録であり解説Blogではないです )

2016-07-01から1ヶ月間の記事一覧

Round #298 A-Exam|Codeforces

Codeforces Round #298 A-Exam を解きました。 #include <bits/stdc++.h> #define REP2(i,x,n) for(int i=x; i<(n); i++) using namespace std; struct CWW{CWW(){ios::sync_with_stdio(false);cin.tie(0);}}cww; int main() { int N; cin >> N; if( N <= 2 ) { cout << 1 <</bits/stdc++.h>…

Round #326 A. Duff and Meat|Codeforces

Problem - A - Codeforces を解きました。 ktnさんに適度な問題をいくつかpick upして頂いたのですがそのうちの1問です。 (適度な問題:私のレベルに対しての適度)Duffちゃんが必要な肉の量/day と コスト/day がN日分与えられるので、 必要な肉を買う最小コ…

再帰④|トリボナッチ数列

#include <bits/stdc++.h> using namespace std; //再帰 - トリボナッチ int trib( int N ) { if( N == 0 || N == 1 )//基底部 { return 0; } else if( N == 2 )//基底部 { return 1; } else //再帰部 { return trib( N - 1 ) + trib( N - 2 ) + trib( N - 3 ); } } int mai</bits/stdc++.h>…

再帰③|フィボナッチ数列

#include <bits/stdc++.h> using namespace std; //再帰 - フィボナッチ int fib( int N ) { if( N == 0 )//基底部 { return 0; } else if( N == 1 )//基底部 { return 1; } else //再帰部 { return ( fib( N - 2 ) + fib( N - 1 ) ); } } int main() { cin.tie(0); ios::sy</bits/stdc++.h>…

再帰②|階乗

#include <bits/stdc++.h> using namespace std; //再帰 - 階乗 int sum( int N ) { if( N == 0 ) //基底部 { return 1; } else //再帰部 { return N * sum( N - 1 ); } } int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; cout << sum( N ) << end</bits/stdc++.h>…

再帰①|等差数列の和

#include <bits/stdc++.h> using namespace std; int sum( int N ) { if( N == 0 ) //基底部 { return 0; } else //再帰部 { return sum( N - 1 ) + 1; } } int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; cout << sum(n) << endl; return 0; } </bits/stdc++.h>…