codeforces水题100道 第十八题 Codeforces Round #289 (Div. 2, ACM ICPC Rules) A. Maximum in Table (brute force)

题目链接:http://www.codeforces.com/problemset/problem/509/A
题意:f[i][1]=f[1][i]=1,f[i][j]=f[i-1][j]+f[i][j-1],求f[n][n]。
C++代码:

#include <iostream>
using namespace std;
int n, f[11][11];
int main()
{
    cin >> n;
    for (int i=1;i<=n;i++)
        f[i][1] = f[1][i] = 1;
    for (int i = 2; i <= n; i ++)
        for (int j = 2; j <= n; j ++)
            f[i][j] = f[i-1][j] + f[i][j-1];
    cout << f[n][n];
    return 0;
}

C++

时间: 2024-08-04 05:33:45

codeforces水题100道 第十八题 Codeforces Round #289 (Div. 2, ACM ICPC Rules) A. Maximum in Table (brute force)的相关文章

Codeforces Round #289 (Div. 2, ACM ICPC Rules) (A, B, C, E)

A:水题,根据题目预处理一下输出即可 B:先把最大和最小找出来,可以让最小全是1,然后最大比最小多出的部分就放1,2,3,4,5...所以如果MAX - MIN > k就是NO,不然就根据这个构造出答案 C:贪心的策略,每次要让数字尽量小,那么就和上一个数字比较,如果需要的和比上一个小,就先找到一个新数字,使得和小于所需数字,并且该数字是大于上一个数字的最小值,找的方法就是从末尾不断放0进位.那么现在情况就只剩下需要的和比上一个大的了,这个就贪心,从末尾尽量变成9即可 E:一个计数问题,其实只要

Codeforces Round #289 (Div. 2, ACM ICPC Rules)——B贪心——Painting Pebbles

There are n piles of pebbles on the table, the i-th pile contains ai pebbles. Your task is to paint each pebble using one of the k given colors so that for each color c and any two piles i and j the difference between the number of pebbles of color c

Codeforces Round #289 (Div. 2, ACM ICPC Rules)

A题: 有一个n*n的矩阵,矩阵的第一行和第一列的值都为1,其余的有: a[i][j]=a[i-1][j]+a[i][j-1]; 现在给出一个n求出这个n*n的矩阵中最大的数. 显然,最大的数就是a[n][n]. 因为n<=10,所以先预处理出一个10*10的矩阵,然后每输入一个n,直接输出a[n][n]. 1 #include<cstdio> 2 int maze[11][11]; 3 int main() 4 { 5 for(int i=1;i<=10;i++) 6 maze[

codeforces水题100道 第二十五题 Codeforces Round #197 A. Helpful Maths (Div. 2) (strings)

题目链接:http://www.codeforces.com/problemset/problem/339/A题意:重新组合加法字符串,使得按照1,2,3的顺序进行排列.C++代码: #include <iostream> #include <string> using namespace std; int cnt[3]; string s, ans = ""; int main() { cin >> s; int len = s.length();

codeforces水题100道 第二十六题 Codeforces Beta Round #95 (Div. 2) A. cAPS lOCK (strings)

题目链接:http://www.codeforces.com/problemset/problem/131/A题意:字符串大小写转换.C++代码: #include <cstdio> #include <cstring> char s[110]; bool islow(char c) { return c >= 'a' && c <= 'z'; } char up(char c) { return c - 32; } char low(char c) {

codeforces水题100道 第二十四题 Codeforces Beta Round #85 (Div. 2 Only) A. Petya and Strings (strings)

题目链接:http://www.codeforces.com/problemset/problem/112/A题意:忽略大小写,比较两个字符串字典序大小.C++代码: #include <cstdio> #include <cstring> int cmp(char *s, char *t) { while (*s) { if (*s <= 'Z') *s += 32; if (*t <= 'Z') *t += 32; if (*s < *t) return -1

codeforces水题100道 第十六题 Codeforces Round #164 (Div. 2) A. Games (brute force)

题目链接:http://www.codeforces.com/problemset/problem/268/A题意:足球比赛中如果主场球队的主场球衣和客队的客队球衣颜色一样,那么要求主队穿上他们的可对球衣,现在有n个球队,每一球队的主场球衣和客场球衣的颜色都告诉你了,它们两两之间要比一场赛.求其中主队穿客场球衣的比赛场数.C++代码: #include <iostream> using namespace std; const int maxn = 33; int x[maxn], y[max

codeforces水题100道 第十四题 Codeforces Round #321 (Div. 2) A. Kefa and First Steps (brute force)

题目链接:http://www.codeforces.com/problemset/problem/580/A题意:求最长连续非降子序列的长度.C++代码: #include <iostream> using namespace std; const int maxn = 100100; int n, a[maxn], tmp, ans; int main() { cin >> n; for (int i = 0; i < n; i ++) cin >> a[i]

codeforces水题100道 第十五题 Codeforces Round #262 (Div. 2) A. Vasya and Socks (brute force)

题目链接:http://www.codeforces.com/problemset/problem/460/A题意:Vasya每天用掉一双袜子,她妈妈每m天给他送一双袜子,Vasya一开始有n双袜子,请问第几天的时候Vasya会没有袜子穿?C++代码: #include <iostream> using namespace std; int n, m; int main() { cin >> n >> m; int d = 0; while (n) { d ++; if