2017 Multi-University Training Contest - 1
hdu 6033
pragma comment(linker, "/STACK:102400000,102400000")
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <string>
#include <complex>
#define ll __int64
#define mod 1000000007
using namespace std;
int n;
int main()
{
int t=;
while(scanf("%d",&n)!=EOF){
printf("Case #%d: %d\n",++t,(int)(n*(log()/log())));
}
return ;
}
hdu 6034
#pragma comment(linker, "/STACK:102400000,102400000")
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <string>
#include <complex>
#define ll long long
#define mod 1000000007
using namespace std;
int n;
char a[];
map<char,int>mp;
int num[][];
int ans[];
struct node
{
char what;
int maxn;
} N[];
bool cmp(struct node aa,struct node bb)
{
if(aa.maxn>bb.maxn)
return true;
else
{
if(aa.maxn==bb.maxn)
{
for(int j=aa.maxn-; j>=; j--)
{
if(num[aa.what-'a'][j]!=num[bb.what-'a'][j])
return num[aa.what-'a'][j]>num[bb.what-'a'][j];
}
}
}
return false;
}
int main()
{
int s=;
while(scanf("%d",&n)!=EOF)
{
mp.clear();
for(int i=; i<=; i++)
{
memset(num[i],,sizeof(num[i]));
N[i].what=i+'a';
N[i].maxn=;
ans[i]=-;
}
for(int i=; i<=n; i++)
{
scanf("%s",a);
int lena=strlen(a);
if(lena>)
mp[a[]]=;
for(int j=; j<lena; j++)
{
num[a[j]-'a'][lena--j]+=;
N[a[j]-'a'].maxn=max(N[a[j]-'a'].maxn,lena--j+);
}
}
for(int i=; i<=; i++)
{
ll be=;
for(int j=; j<N[i].maxn; j++)
{
ll ok=(be+num[i][j])%;
be=(be+num[i][j])/;
num[i][j]=ok;
}
int jishu=N[i].maxn;
while(be>)
{
num[i][jishu]=be%;
be/=;
jishu++;
}
N[i].maxn=jishu;
} sort(N,N+,cmp);
for(int i=; i>=; i--)
{
if(mp[N[i].what]==)
{
ans[i]=;
break;
}
}
int jishu=;
for(int i=; i<=; i++)
{
if(ans[i]==-)
{
ans[i]=jishu;
jishu--;
}
}
ll re=;
for(int i=; i<=; i++)
{
if(ans[i]!=)
{
ll gg=;
for(int j=; j<N[i].maxn; j++)
{
re=(re+gg*(num[N[i].what-'a'][j]*ans[i])%mod)%mod;
gg*=;
gg%=mod;
}
} }
cout<<"Case #"<<++s<<": "<<re<<endl;
}
return ;
}
hdu 6035
#pragma comment(linker, "/STACK:102400000,102400000")
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <string>
#include <complex>
#define ll long long
#define mod 1000000007
using namespace std;
ll n;
ll pre[];
ll used[];
ll siz[];
ll sum[];
ll col[];
ll gg[];
struct node
{
ll to;;
ll pre;
} N[];
ll nedge=;
ll ans=;
void init()
{
for(int i=; i<=n; i++){
pre[i]=;
used[i]=;
gg[i]=;
sum[i]=;
siz[i]=;
col[i]=;
}
nedge=;
}
void add(ll st,ll ed)
{
nedge++;
N[nedge].to=ed;
N[nedge].pre=pre[st];
pre[st]=nedge;
}
void dfs(ll root)
{
used[root]=;
siz[root]=;
ll be=sum[col[root]];
ll ad=;
for(int i=pre[root]; i; i=N[i].pre)
{
if(used[N[i].to]==)
{
dfs(N[i].to);
siz[root]+=siz[N[i].to];
ll sonu=sum[col[root]]-be;
ll tmp=siz[N[i].to]-sonu;
ad+=sonu;
ans=ans-tmp*(tmp-)/;
be=sum[col[root]];
} }
sum[col[root]]+=(siz[root]-ad);
}
int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int t=;
while(scanf("%lld",&n)!=EOF)
{
init();
ll jishu=;
for(int i=; i<=n; i++){
scanf("%lld",&col[i]);
if(gg[col[i]]==){
jishu++;
gg[col[i]]=;
}
}
ll a,b;
for(int i=; i<n; i++)
{
scanf("%lld %lld",&a,&b);
add(a,b);
add(b,a);
}
ans=jishu*(n*(n-)/);
dfs();
for(int i=;i<=n;i++){
if(sum[i]!=){
ll res=n-sum[i];
ans=ans-(res-)*res/;
}
}
printf("Case #%d: %lld\n",++t,ans);
}
return ;
}
hdu 6038
#pragma comment(linker, "/STACK:102400000,102400000")
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <string>
#include <complex>
#define ll long long
#define mod 1000000007
using namespace std;
int n,m;
int a[];
int b[];
vector<int> aa;
vector<int> bb;
map<int,int>mp;
int main()
{
int t=;
while(scanf("%d %d",&n,&m)!=EOF)
{
aa.clear();
bb.clear();
mp.clear();
for(int i=; i<n; i++)
scanf("%d",&a[i]);
for(int j=; j<m; j++)
scanf("%d",&b[j]);
for(int i=;i<n;i++)
{
if(mp[i]==)
{
int now=;
mp[i]=;
int s=i;
while(mp[a[s]]==){
now++;
mp[a[s]]=;
s=a[s];
}
aa.push_back(now);
}
}
mp.clear();
for(int i=;i<m;i++)
{
if(mp[i]==)
{
int now=;
mp[i]=;
int s=i;
while(mp[b[s]]==){
now++;
mp[b[s]]=;
s=b[s];
}
bb.push_back(now);
}
}
ll ans=;
for(int i=;i<aa.size();i++){
ll temp=;
for(int j=;j<bb.size();j++){ if(aa[i]%bb[j]==)
temp+=bb[j];
}
ans=(ans*temp)%mod;
}
printf("Case #%d: %lld\n",++t,ans);
}
return ;
}
hdu 6043
#pragma comment(linker, "/STACK:102400000,102400000")
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <string>
#include <complex>
#define ll long long
#define mod 1000000007
using namespace std;
ll n,k;
int main()
{
int t=;
while(scanf("%lld %lld",&n,&k)!=EOF){
if(k<=n)
printf("Case #%d: %lld\n",++t,k);
else
{
ll now;
ll which;
now=(k-n)/(n-);
which=(k-n)%(n-);
if(now%==)
{
if(which==)
printf("Case #%d: %lld\n",++t,n);
else
printf("Case #%d: %lld\n",++t,which);
}
else
{
if(which==)
printf("Case #%d: %lld\n",++t,n-);
else
printf("Case #%d: %lld\n",++t,which);
}
}
}
return ;
}
2017 Multi-University Training Contest - 1的更多相关文章
- 2017 Wuhan University Programming Contest (Online Round) Lost in WHU 矩阵快速幂 一个无向图,求从1出发到达n最多经过T条边的方法数,边可以重复经过,到达n之后不可以再离开。
/** 题目:Lost in WHU 链接:https://oj.ejq.me/problem/26 题意:一个无向图,求从1出发到达n最多经过T条边的方法数,边可以重复经过,到达n之后不可以再离开. ...
- 2017 Wuhan University Programming Contest (Online Round) C. Divide by Six 分析+模拟
/** 题目:C. Divide by Six 链接:https://oj.ejq.me/problem/24 题意:给定一个数,这个数位数达到1e5,可能存在前导0.问为了使这个数是6的倍数,且没有 ...
- 2017 Wuhan University Programming Contest (Online Round) B Color 树形dp求染色方法数
/** 题目:Color 链接:https://oj.ejq.me/problem/23 题意:给定一颗树,将树上的点最多染成m种颜色,有些节点不可以染成某些颜色.相邻节点颜色不同.求染色方法数. 思 ...
- 2017 Wuhan University Programming Contest (Online Round) D. Events,线段树区间更新+最值查询!
D. Events 线段树区间更新查询区间历史最小值,看似很简单的题意写了两天才写出来. 题意:n个数,Q次操作,每次操作对一个区间[l,r]的数同时加上C,然后输出这段区间的历史最小值. 思路:在线 ...
- 2017 Multi-University Training Contest - Team 9 1005&&HDU 6165 FFF at Valentine【强联通缩点+拓扑排序】
FFF at Valentine Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- 2017 Multi-University Training Contest - Team 9 1004&&HDU 6164 Dying Light【数学+模拟】
Dying Light Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Tot ...
- 2017 Multi-University Training Contest - Team 9 1003&&HDU 6163 CSGO【计算几何】
CSGO Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Subm ...
- 2017 Multi-University Training Contest - Team 9 1002&&HDU 6162 Ch’s gift【树链部分+线段树】
Ch’s gift Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total S ...
- 2017 Multi-University Training Contest - Team 9 1001&&HDU 6161 Big binary tree【树形dp+hash】
Big binary tree Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- 2017 Multi-University Training Contest - Team 1 1003&&HDU 6035 Colorful Tree【树形dp】
Colorful Tree Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)T ...
随机推荐
- 422. Length of Last Word【LintCode java】
Description Given a string s consists of upper/lower-case alphabets and empty space characters ' ', ...
- 袋鼠云研发手记 | 袋鼠云EasyManager的TypeScript重构纪要
作为一家创新驱动的科技公司,袋鼠云每年研发投入达数千万,公司80%员工都是技术人员,袋鼠云产品家族包括企业级一站式数据中台PaaS数栈.交互式数据可视化大屏开发平台Easy[V]等产品也在迅速迭代.在 ...
- Fedora 26/27/28网易云音乐安装
信息从 https://www.southcity-oldboy.com/1474.html获取,感谢站长南城旧少年! 以下为前辈网页上的内容 1.安装 RPM Fusion 源 (free): ht ...
- Python序列之字符串 (str)
作者博文地址:http://www.cnblogs.com/spiritman/ Python字符串的常用操作包括以下但不限于以下操作: 字符串的替换.删除.切片.复制.连接.比较.查找.分割等 以下 ...
- php 中关于pdo的使用
之前一段时间,开始了php的研究,看了关于PDO的一些资料,发现不错,整理和总结一下,作为开发笔记,留待日后使用,<PHP开发笔记系列(一)-PDO使用>. PDO是PHP Data Ob ...
- 软件工程-东北师大站-第五次作业(PSP)
1.本周PSP 2.本周进度条 3.本周累计进度图 代码累计折线图 博文字数累计折线图 4.本周PSP饼状图
- 20135313_exp4
实验四 GUI界面的设计和运用 20135313吴子怡 一.实验目的 结合项目,为每个密码学算法设计能够提供使用者用户体验的操作界面,实现加解密.求得消息摘要的功能. 二.代码举例(备注:其 ...
- BETA版本前冲刺准备
[团队概要] 团队项目名:小葵日记 团队名:日不落战队 队员及角色: 队员 角色 备注 安琪 前端工程师 队长 佳莹 前端工程师 智慧 后端工程师 章鹏 后端工程师 语恳 UI设计师 炜坤 前端工程师 ...
- 《DWZ笔记一》<select>动态联动菜单
联动菜单,即组合框Combo box,在DWZ文档中对组合框combox的是这样描述的: 在传统的select 用class 定义:class=”combox”, html 扩展:保留原有属性name ...
- 转 使用Docker部署 spring-boot maven应用
转自:https://blog.csdn.net/u011699931/article/details/70226504/ 使用Docker部署 spring-boot maven应用 部署过程分为以 ...