Google Round B APAC Test

A:题意密码由n不同的字符和m的长度组成,问你有多少种情况

解题思路:可以得到状态转移方程为  dp[i][j] = dp[i-1][j]*j + dp[i-1][j-1]*(n-j+1);

解题代码:

 1 // File Name: a.cpp
 2 // Author: darkdream
 3 // Created Time: 2014年09月15日 星期一 14时29分39秒
 4
 5 #include<vector>
 6 #include<list>
 7 #include<map>
 8 #include<set>
 9 #include<deque>
10 #include<stack>
11 #include<bitset>
12 #include<algorithm>
13 #include<functional>
14 #include<numeric>
15 #include<utility>
16 #include<sstream>
17 #include<iostream>
18 #include<iomanip>
19 #include<cstdio>
20 #include<cmath>
21 #include<cstdlib>
22 #include<cstring>
23 #include<ctime>
24 #define LL long long
25
26 using namespace std;
27 LL dp[200][200];
28 #define M 1000000007
29 int main(){
30     freopen("out","w",stdout);
31    int t;
32    scanf("%d",&t);
33    for(int ca = 1; ca <= t; ca ++)
34    {
35      int n , m ;
36      scanf("%d %d",&n,&m);
37      memset(dp,0,sizeof(dp));
38      dp[1][1] = n;
39      for(int i = 2;i <= m;i ++)
40      {
41         for(int j = 1;j <= n;j ++)
42          dp[i][j] = (dp[i-1][j] *j)%M + dp[i-1][j-1]*(n-j+1)%M ;
43      }
44     printf("Case #%d: %lld\n",ca,dp[m][n]%M);
45    }
46 return 0;
47 }

时间: 2024-08-03 20:34:01

Google Round B APAC Test的相关文章

google Round D APAC Test 2017 题解

首先说明一下:我只是用暴力过了4道题的小数据,就是简单的枚举,大数据都不会做!下面的题解,是我从网上搜到的解答以及查看排行榜上大神的答案得出来的. 首先贴一下主要的题解来源:http://codeforces.com/blog/entry/47796,基本上解题思路都是从这里看到的,你可以直接查看这个链接,或者看下面的题解. 还有排行榜大神们的答案,https://code.google.com/codejam/contest/5264486/scoreboard?c=5264486#vf=1,

2017 google Round C APAC Test 题解

题解参考网上的答案,以及我自己的想法. 主要参考网站:http://codeforces.com/blog/entry/47181,http://codeforces.com/blog/entry/47185.讲的都非常仔细,我建议看这个上面的题解,开拓思路,然后就是看排行榜上大神们的答案,当然可以直接看下面我的题解. 第一题 1.看懂题意很重要,如果理解了怎么计算,代码应该很快就写出来.maximum possible expected number,求最大期望个数,就是一个位置可以访问多次,

Round B APAC Test 2016

Problem A There are N cities in Chelsea's state (numbered starting from 1, which is Chelsea's city), and M bidirectional roads directly connect them. (A pair of cities may even be directly connected by more than one road.) Because of changes in traff

第一周 8.29 - 9.4

开学了>_< 8.29 Round B APAC Test 2017 B. Sherlock and Watson Gym Secrets 昨天下午做了下 g 家的笔试..真的好菜啊..差好远..好好补下题叭 给出 n,A,B,k ,使得( i^A + j^B) % k == 0 的 i ,j 有多少对(i != j , 1 <= i <= n , 1 <= j <= n) 可以按照 模 k 的余数分类 然后 将 两边的余数 组合起来 cnt[x] * cnt[k-x]

Google Code Jam 2014 Round 2回顾和分析

回顾 比赛开始网络就一直在抽风,不知道宿舍网渣还是有人攻击服务器.刷了n遍n久刷出了题目.提交A小case的时候眼睁睁看着时间过去,却提交不上,这破网.最后A题B题还是解决了,C题扫了一眼,读都没读,就奔D题去了,因为我看到了熟悉的trie这个单词,加之看到小case只有9分,判断小case应该比较容易.前面因为网络浪费了很多时间,加之从未编过trie的程序,只能临时上网翻书去学,最后D小这个可以很容易暴力解的问题也没编完. 最终的rank是13xx,考虑到在这次GCJ之前从未接触过编程竞赛,而

Google Code Jam 2009, Round 1C C. Bribe the Prisoners (记忆化dp)

Problem In a kingdom there are prison cells (numbered 1 to P) built to form a straight line segment. Cells number i and i+1 are adjacent, and prisoners in adjacent cells are called "neighbours." A wall with a window separates adjacent cells, and

google kcikstart 2018 round c

https://code.google.com/codejam/contest/4384486/dashboard#s=p0 A 题意 给定一个无向图,其中存在着唯一的一个环,求每个点到这个环的最短距离. 数据范围 ≤ T ≤ 100. 1 ≤ xi ≤ N, for all i. 1 ≤ yi ≤ N, for all i. xi ≠ yi, for all i. (xi, yi) ≠ (xj, yj), for all i ≠ j. The graph in which planets ar

Google Kickstart 2020 Round A: Plates Solution

Problem Statement Problem Dr. Patel has N stacks of plates. Each stack contains K plates. Each plate has a positive beauty value, describing how beautiful it looks. Dr. Patel would like to take exactly P plates to use for dinner tonight. If he would

Google Code Jam 2014 Round 1B Problem B

二进制数位DP,涉及到数字的按位与操作. 查看官方解题报告 #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> using namespace std; #define MAX_LEN 50 long long A, B, K; int a[MAX_LEN], b[MAX_LEN], k[MAX_LEN]; long long memoize[MAX_LEN]