2017 Multi-University Training Contest - 3
HDU 6058
#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
#include <cstdlib>
#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 t;
int a[];
int l[];
int r[];
int n,k;
int main()
{
scanf("%d",&t);
for(int i=;i<=t;i++){
LL ans=;
scanf("%d %d",&n,&k);
for(int j=;j<n;j++)
scanf("%d",&a[j]);
for(int j=;j<n;j++){
int s,t;
int c1=,c2=;
for(s=j+;s<n;s++){
if(c1>k)
break;
if(a[s]>a[j])
r[c1++]=s-j;
}
if(s>=n)
r[c1]=n-j;
for(t=j-;t>=;t--){
if(c2>k)
break;
if(a[t]>a[j])
l[c2++]=j-t;
}
if(t<=)
l[c2]=j+;;
for(int o=;o<c2;o++){
if(k-o->=c1)
continue;
ans=ans+1LL*a[j]*(l[o+]-l[o])*(r[k-o]-r[k-o-]);
}
}
printf("%lld\n",ans);
}
return ;
}
HDU 6060
#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
#include <cstdlib>
#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,k;
struct node
{
int st,ed;
LL w;
}N[];
int pre[];
LL www[];
int dp[]; int nedge=;
void init()
{
nedge=;
memset(pre,,sizeof(pre));
memset(www,,sizeof(www));
memset(dp,,sizeof(dp));
memset(N,,sizeof(N));
}
void add(int s,int t,LL we)
{
nedge++;
N[nedge].ed=t;
N[nedge].w=we;
N[nedge].st=pre[s];
pre[s]=nedge;
}
int dfs(int root ,int fa)
{
dp[root]=;
for(int i=pre[root];i;i=N[i].st)
{
if(N[i].ed!=fa){
www[N[i].ed]=N[i].w;
dp[root]+=dfs(N[i].ed,root);
}
}
return dp[root];
}
int main()
{
while(scanf("%d %d",&n,&k)!=EOF){
int a,b;
LL c;
init();
for(int i=;i<n;i++){
scanf("%d %d %lld",&a,&b,&c);
add(a,b,c);
add(b,a,c);
}
dfs(,-);
LL ans=;
for(int i=;i<=n;i++)
{
ans=ans+1LL*min(dp[i],k)*www[i];
}
printf("%lld\n",ans);
}
return ;
}
HDU 6063
#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
#include <cstdlib>
#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;
LL fun(LL n,LL k){
LL ans=;
LL b=n;
while(k){
if(k%==){
ans=(ans*b)%mod;
}
k/=;
b=b%mod;
b=(b*b)%mod;
}
return ans;
}
int main()
{
int t=;
while(scanf("%lld %lld",&n,&k)!=EOF){
printf("Case #%d: %lld\n",++t,fun(n,k));
}
return ;
}
HDU 6066
#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
#include <cstdlib>
#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 t;
int main()
{
int ans,exm;
scanf("%d",&t);
ans=;
for(int i=; i<=t; i++)
{
scanf("%d",&exm);
if(exm<=)
ans++;
}
printf("%d\n",ans);
return ;
}
2017 Multi-University Training Contest - 3的更多相关文章
- 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 ...
随机推荐
- 编写和调试Android下JNI程序流程
1,切换到Android目录下bin/classes,使用javah命令生成jni所需的头文件,命令类似于:javah com.xxx.ooo,其中,com.xxx为package名称,ooo为包含n ...
- 如何在静态方法或非Spring Bean中注入Spring Bean
在项目中有时需要根据需要在自己new一个对象,或者在某些util方法或属性中获取Spring Bean对象,从而完成某些工作,但是由于自己new的对象和util方法并不是受Spring所 ...
- Scrum立会报告+燃尽图(Final阶段第五次)
此作业要求参见:https://edu.cnblogs.com/campus/nenu/2018fall/homework/2484 项目地址:https://coding.net/u/wuyy694 ...
- 软件工程-东北师大站-第十二次作业(PSP)
1.本周PSP 2.本周进度条 3.本周累计进度图 代码累计折线图 博文字数累计折线图 4.本周PSP饼状图
- [buaa-SE-2017]结对项目-数独程序扩展
结对项目-数独程序扩展 step1~step3:github:SE-Sudoku-Pair-master step4:github:SE-Sudoku-Pair-dev-combine step5:g ...
- Servlet以流的形式返回图片
代码: import java.awt.image.BufferedImage; import java.io.File; import java.io.FileInputStream; import ...
- HTML和CSS <h1> --2-- <h1>
认识html文件基本结构 这一节中我们来学习html文件的结构:一个HTML文件是有自己固定的结构的. <html> <head>...</head> <bo ...
- java对文件的操作
1.按字节读取文件内容2.按字符读取文件内容3.按行读取文件内容 4.随机读取文件内容 public class ReadFromFile { /** * 以字节为单位读取文件,常用 ...
- 《构建之法》第四&十七章读书笔记
<构建之法>第四&十七章读书笔记 一. 前言 再次阅读<构建之法>,愈发被其中生动有趣的举例吸引.作为一本给予软件工程学生的书籍,其不以枯燥的理论知识 ...
- 25_IO_第25天(Properties、序列化流、打印流、CommonsIO)_讲义
今日内容介绍 1.Properties集合 2.序列化流与反序列化流 3.打印流 4.commons-IO 01Properties集合的特点 * A: Properties集合的特点 * a: Pr ...