题意:如图所示,求出空白格子的数量
链接:http://codeforces.com/problemset/problem/70/A
思路:根据小数据,可以推出f(n) = f(n-1) * 3
注意点:无
以下为AC代码:
# | Author | Problem | Lang | Verdict | Time | Memory | Sent | Judged |
---|---|---|---|---|---|---|---|---|
9738590 | Practice: luminous11 | 70A - 28 | GNU C++11 | Accepted | 30 ms | 4 KB | 2015-02-06 20:15:21 | 2015-02-06 20:15:22 |
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>
#include <deque>
#include <list>
#include <cctype>
#include <algorithm>
#include <climits>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <cstdlib>
#include <ctime>
#define ll long long
#define ull unsigned long long
#define all(x) (x).begin(), (x).end()
#define clr(a, v) memset( a , v , sizeof(a) )
#define pb push_back
#define mp make_pair
#define read(f) freopen(f, "r", stdin)
#define write(f) freopen(f, "w", stdout)
using namespace std;
const double pi = acos(-1);
int main()
{
ios::sync_with_stdio( false );
int num[1005] = { 1, 1, 3, };
for ( int i = 3; i < 1005; i ++ ){
num[i] = ( 3 * num[i-1] ) % 1000003;
}
int n;
while ( cin >> n ){
cout << num[n] << endl;
}
return 0;
}