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; ...
随机推荐
- OpenCV 基础知识------图像创建、访问、转换
cvCreateImage函数-- Cxcore数组操作 创建头并分配数据 IplImage* cvCreateImage( CvSize size, int depth, int channels ...
- Servlet Filter 过滤器
Filter也称之为过滤器,它是Servlet技术中最激动人心的技术,WEB开发人员通过Filter技术,对web服务器管理的所有web资源: 例如Jsp, Servlet, 静态图片文件或静态 ht ...
- 单元测试、自动化测试、接口测试过程中的Excel数据驱动(java实现)
import java.io.FileInputStream;import java.io.InputStream;import java.util.HashMap;import java.util. ...
- DrawerLayout和ActionBarDrawerToggle
说明:DrawerLayout的作用就是左侧滑出.右侧滑出菜单.需要和ActionBarDrawerToggle来配合使用.如果对ActionBar不理解,请先熟悉ActionBar. 1.首先配置D ...
- CDockablepane风格设置
屏蔽掉pane右上角的几个按钮 即将CDockablePane右上角的三个按钮屏蔽. 1 去掉关闭按钮 在CDockablePane的派生类中,重写方法CanBeClosed即可 ...
- 好的 小图标 html
只需引用样式,加入字体文件到项目中就可实现 <link href="css/font-awesome.min.css" rel="stylesheet"& ...
- 【转】你必须了解的Session的本质
有一点我们必须承认,大多数web应用程序都离不开session的使用.这篇文章将会结合php以及http协议来分析如何建立一个安全的会话管理机制.我们先简单的了解一些http的知识,从而理解该协议的无 ...
- Servlet程序开发--Servlet 与 表单
servlet程序: doPost方法时为了防止表单提交时post方式的问题.否则只能处理get请求 package org.lxh.servletdemo ; import java.io.* ; ...
- cisco 密码重置
密码重置 分类: 转贴技术资料 2007-12-28 16:38 http://www.cisco.com/en/US/products/hw/routers/ps259/products_passw ...
- 关于tomcat启动没有进行编译或者编译报错的问题
关于tomcat 的问题 如果项目没有编译 解决方案:1: 把项目刷新一下 然后Clean一下,之后等待右下角编译完成100%2: 有可能tomcat conf 里的配置文件的错误 进入查看下3: 如 ...