codeforces #309 DIV2
这场并没有做,做的赛后的,太晚了时间,中午做了两题,稍微贴一下,剩余的题目本周争取补完
A题:
链接:http://codeforces.com/contest/554/problem/A
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<algorithm>
using namespace std;
string s;
int main()
{
while(cin>>s)
{
int n=s.length();
cout<<n*+<<endl;
}
return ;
}
B题:
链接:http://codeforces.com/contest/554/problem/B
其实就是判相等的行数
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;
const int maxn=;
string s[maxn];
int main()
{
int n;
while(cin>>n)
{
for(int i=;i<n;i++)
cin>>s[i];
int mx=;
int cnt;
for(int i=;i<n;i++)
{
cnt=;
for(int j=;j<n;j++) //找到一样的行就行了
if(s[i]==s[j])
cnt++;
if(cnt>mx)
mx=cnt;
}
cout<<mx<<endl;
}
return ;
}
剩余的题目本周末一定争取补完
继续补题中,今天补得是C题,这题非常有意思,经典的组合计数,很有数学的味道,开始完全没思路,后来跟王远立和李大神讨论,王远立给我了思路,启发了我,之后晚上又参看了一下题解,终于A了,还学会了求组合数一个比较好的办法,不用阶乘,用公式:
,非常好
题目链接:http://codeforces.com/contest/554/problem/C
贴一下神牛的思路,非常清晰易懂:http://blog.csdn.net/libin56842/article/details/46650209
非常好的插空法
下面是我的代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<stack>
#define mod 1000000007
using namespace std;
const int maxn=+;
int a[maxn];
long long dp[maxn][maxn];
void pre() //很好的求组合数的方法
{
dp[][]=;
for(int i=;i<maxn;i++)
{
dp[i][i]=;
dp[i][]=;
for(int j=;j<i;j++)
dp[i][j]=(dp[i-][j]+dp[i-][j-])%mod;
}
}
int main()
{
int k;
pre();
while(cin>>k)
{
int total=;
for(int i=;i<k;i++)
{
cin>>a[i];
total+=a[i];
}
long long res=;
for(int i=k-;i>;i--)
{
res*=dp[total-][a[i]-];
res%=mod;
total-=a[i];
}
cout<<res<<endl;
}
return ;
}
D题明天在补,这次争取尝试尝试D
D题:
链接:http://codeforces.com/problemset/problem/553/B
先来说说题意吧,就是有一串数p[n],然后1到n分别映射到p[1]到p[n],比如:p = [4, 1, 6, 2, 5, 3]得到(142)(36)(5), 1被4代表, 4被2代表, 2被1代表, 3和6互换, 5保持原来位置不变。然后进行循环左移,将每个周期排序,在将周期之间的第一个元素排序排序,得到如下:(421)(5)(63)。然后求最终变化之后跟原来序列相同的,并且第k种排列
codeforces #309 DIV2的更多相关文章
- Codeforces #180 div2 C Parity Game
// Codeforces #180 div2 C Parity Game // // 这个问题的意思被摄物体没有解释 // // 这个主题是如此的狠一点(对我来说,),不多说了这 // // 解决问 ...
- Codeforces #541 (Div2) - E. String Multiplication(动态规划)
Problem Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Descriptio ...
- Codeforces #541 (Div2) - F. Asya And Kittens(并查集+链表)
Problem Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Inp ...
- Codeforces #541 (Div2) - D. Gourmet choice(拓扑排序+并查集)
Problem Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input ...
- Codeforces #548 (Div2) - D.Steps to One(概率dp+数论)
Problem Codeforces #548 (Div2) - D.Steps to One Time Limit: 2000 mSec Problem Description Input Th ...
- 【Codeforces #312 div2 A】Lala Land and Apple Trees
# [Codeforces #312 div2 A]Lala Land and Apple Trees 首先,此题的大意是在一条坐标轴上,有\(n\)个点,每个点的权值为\(a_{i}\),第一次从原 ...
- Codeforces #263 div2 解题报告
比赛链接:http://codeforces.com/contest/462 这次比赛的时候,刚刚注冊的时候非常想好好的做一下,可是网上喝了个小酒之后.也就迷迷糊糊地看了题目,做了几题.一觉醒来发现r ...
- codeforces #round363 div2.C-Vacations (DP)
题目链接:http://codeforces.com/contest/699/problem/C dp[i][j]表示第i天做事情j所得到最小的假期,j=0,1,2. #include<bits ...
- codeforces round367 div2.C (DP)
题目链接:http://codeforces.com/contest/706/problem/C #include<bits/stdc++.h> using namespace std; ...
随机推荐
- PID控制学习笔记(二)
不管是基本的PID控制还是变形的PID控制算法,其核心都是对输入信号(设定值信号.测量信号或者偏差信号等)做基本的比例.积分.微分运算,最终提供给被控过程良好的调节信号. 在过程控制仪表,特别是在数字 ...
- UIView的layoutSubviews,initWithFrame,initWithCoder方法
****************************layoutSubviews************************************ layoutSubviews是UIView ...
- FZU Problem 1895 整除45问题(整除问题+字符串维护+优化)
这个题有点烧脑啊,但是只要想清楚被45整除的数,肯定能被5和9整除,能被9整除的数各位加起来肯定是9的倍数,能被5整除的末尾是0或5. 然后dfs的过程稍微不太好懂,还有几个优化必须要注意.dfs的过 ...
- Cloudsim 3.0在myclipse下的安装过程
(1)下载cloudsim 3.0: http://code.google.com/p/cloudsim/downloads/list (2)下载flanaga.jar包 下载地址:http://w ...
- 2016中国大学生程序设计竞赛 - 网络选拔赛 1011 Lweb and String
Problem Description Lweb has a string S. Oneday, he decided to transform this string to a new sequen ...
- C++:预处理指令
Preprocessor directives 预处理器指令 预处理器指令是指那些包含在我们代码中的预处理器语句行,这些预处理器语句不是真正的代码语句,但是他们指导程序如何进行编译.这些语句总是以 ‘ ...
- heartbeat集群安装配置
安装配置高可用集群需要注意:1.节点名称:集群每个节点的名称都得能互相解析 /etc/hosts hosts主机名的正反解析结果必须跟"uname -n"的结果保持一致2.时间必须 ...
- Windows 2003】利用域&&组策略自动部署软件
Windows 2003]利用域&&组策略自动部署软件 转自 http://hi.baidu.com/qu6zhi/item/4c0fa100dc768613cc34ead0 ==== ...
- PAT1064(上)分析部分
Complete Binary Search Tree (30) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B A Binary Search Tree (BST) ...
- 使用maven开发过程中,pom报的一些错的解决方法
1. maven-resources-plugin prior to 2.4 is not supported by m2e. Use maven- resources-plugin versio ...