这套题是叉姐出的,好难啊,先扫一遍好像没有会做的题了,仔细一想好像D最容易哎

Super Resolution

Accepted : 112   Submit : 178
Time Limit : 1000 MS   Memory Limit : 65536 KB 

Super Resolution

Bobo has an n×m picture consists of black and white pixels. He loves the picture so he would like to scale it a×b times. That is, to replace each pixel with a×b block of pixels with the same color (see the example for clarity).

Input

The input contains zero or more test cases and is terminated by end-of-file. For each test case,

The first line contains four integers n,m,a,b. The i-th of the following n lines contains a binary string of length m which denotes the i-th row of the original picture. Character "0" stands for a white pixel while the character "1" stands for black one.

  • 1≤n,m,a,b≤10
  • The number of tests cases does not exceed 10.

Output

For each case, output n×a rows and m×b columns which denote the result.

Sample Input

2 2 1 1
10
11
2 2 2 2
10
11
2 2 2 3
10
11

Sample Output

10
11
1100
1100
1111
1111
111000
111000
111111
111111

水题直接开搞,就是我把图像放大m*n倍,那不就是周围都是它的重复了,循环搞下。

#include<stdio.h>
int main(){
int n,m,a,b;
while(~scanf("%d%d%d%d",&n,&m,&a,&b)){
getchar();
char s[];
while(n--){
gets(s);
for(int k=;k<a;k++){
for(int i=;i<m;i++){
for(int j=;j<b;j++)
printf("%c",s[i]);
}
printf("\n");
}}} return ;}

然后我也没有会做的题了,群里讲I是脑洞题,我就直接开搞了

Strange Optimization

Accepted : 38   Submit : 209
Time Limit : 1000 MS   Memory Limit : 65536 KB 

Strange Optimization

Bobo is facing a strange optimization problem. Given n,m, he is going to find a real number α such that f(12+α) is maximized, where f(t)=mini,j∈Z|i/n−j/m+t|. Help him!

Note: It can be proved that the result is always rational.

Input

The input contains zero or more test cases and is terminated by end-of-file.

Each test case contains two integers n,m.

  • 1≤n,m≤109
  • The number of tests cases does not exceed 104.

Output

For each case, output a fraction p/q which denotes the result.

Sample Input

1 1
1 2

Sample Output

1/2
1/4

Note

For the first sample, α=0 maximizes the function.

这个题我好像不会哎,这个脑洞开的,1/(m*n*2),这是我第一次猜的,错了啊,接下来我的方向就是找i/n-j/m的最小区间了,毕竟后面的数是个实数,这个答案符合最小公倍数啊,交上去wa,后来才发现是爆int,知道了又发现这个OJ是int64,求心理面积大小

#include <stdio.h>
__int64 gcd(__int64 a,__int64 b)
{
while(b != )
{
__int64 r = b;
b = a % b;
a = r;
}
return a;
}
int main()
{
__int64 m,n;
while(~scanf("%I64d%I64d",&n,&m)){
printf("1/%I64d\n",m/gcd(n,m)*n*);
}
return ;
}

Highway

Accepted : 37   Submit : 151
Time Limit : 4000 MS   Memory Limit : 65536 KB 

Highway

In ICPCCamp there were n towns conveniently numbered with 1,2,…,n connected with (n−1) roads. The i-th road connecting towns ai and bi has length ci. It is guaranteed that any two cities reach each other using only roads.

Bobo would like to build (n−1) highways so that any two towns reach each using only highways. Building a highway between towns x and y costs him δ(x,y) cents, where δ(x,y) is the length of the shortest path between towns x and y using roads.

As Bobo is rich, he would like to find the most expensive way to build the (n−1) highways.

Input

The input contains zero or more test cases and is terminated by end-of-file. For each test case:

The first line contains an integer n. The i-th of the following (n−1) lines contains three integers ai, bi and ci.

  • 1≤n≤105
  • 1≤ai,bi≤n
  • 1≤ci≤108
  • The number of test cases does not exceed 10.

Output

For each test case, output an integer which denotes the result.

Sample Input

5
1 2 2
1 3 1
2 4 2
3 5 1
5
1 2 2
1 4 1
3 4 1
4 5 2

Sample Output

19
15

这个题似曾相识,先DFS两次求最长路,树的直径,和蓝桥杯大臣的旅费差不多,然后再其他点到这两个点最长的距离得和。我是做不出来

和hdu2916差不多

都是树形dp,那个题的代码

#include <bits/stdc++.h>
using namespace std;
int len;
int head[],dp[],id[],dp2[],id2[];
//dp[i],从i往下倒叶子的最大距离
//id,最大距离对应的序号
//dp2,次大距离
//id2,次大序号
struct node {
int now,next,len;
} tree[];
void add(int x,int y,int z) { //建树
tree[len].now = y;
tree[len].len = z;
tree[len].next = head[x];
head[x] = len++;
tree[len].now = x;
tree[len].len = z;
tree[len].next = head[y];
head[y] = len++;
}
void dfs1(int root,int p) {
//从节点root往下倒叶子节点的最大距离
//p是root父节点
int i,j,k,tem;
dp[root] = ;
dp2[root] = ;
for(i = head[root]; i!=-; i = tree[i].next) {
k = tree[i].now;
if(k == p)//不能再找父节点
continue;
dfs1(k,root);
if(dp2[root]<dp[k]+tree[i].len) { //比次大的要大
dp2[root] = dp[k]+tree[i].len;
id2[root] = k;
if(dp2[root]>dp[root]) { //次大大于最大,交换其值与id
swap(dp2[root],dp[root]);
swap(id2[root],id[root]);
}
}
}
}
//len为p到root的长度
void dfs2(int root,int p) {
//从父亲节点开始更新
int i,j,k;
for(i = head[root]; i!=-; i = tree[i].next) {
k = tree[i].now;
if(k == p)
continue;
if(k == id[root]) { //最大距离的序号,对应的是dp[k],多以这里要加次大的
if(tree[i].len+dp2[root]>dp2[k]) {
dp2[k] = tree[i].len+dp2[root];
id2[k] = root;
if(dp2[k]>dp[k]) {
swap(dp2[k],dp[k]);
swap(id2[k],id[k]);
}
}
} else {
if(tree[i].len+dp[root]>dp2[k]) {
dp2[k] = tree[i].len+dp[root];
id2[k] = root;
if(dp2[k]>dp[k]) {
swap(dp2[k],dp[k]);
swap(id2[k],id[k]);
}
}
}
dfs2(k,root);
}
}
int main() {
int n,i,j,x,y;
while(~scanf("%d",&n)) {
len = ;
memset(head,-,sizeof(head));
for(i = ; i<=n; i++) {
scanf("%d%d",&x,&y);
add(i,x,y);
}
dfs1(,-);
dfs2(,-);
for(i = ; i<=n; i++)
printf("%d\n",dp[i]);
} return ;
}

2017年 湘潭邀请赛(湖南)or 江苏省赛的更多相关文章

  1. XTU 1264 - Partial Sum - [2017湘潭邀请赛E题(江苏省赛)]

    2017江苏省赛的E题,当时在场上看错了题目没做出来,现在补一下…… 题目链接:http://202.197.224.59/OnlineJudge2/index.php/Problem/read/id ...

  2. XTU 1267 - Highway - [树的直径][2017湘潭邀请赛H题(江苏省赛)]

    这道题可能有毒……总之一会儿能过一会儿不能过的,搞的我很心烦…… 依然是上次2017江苏省赛的题目,之前期末考试结束了之后有想补一下这道题,当时比较懵逼不知道怎么做……看了题解也不是很懂……就只好放弃 ...

  3. XTU 1260 - Determinant - [2017湘潭邀请赛A题(江苏省赛)][高斯消元法][快速幂和逆元]

    是2017江苏省赛的第一题,当时在场上没做出来(废话,那个时候又不懂高斯消元怎么写……而且数论也学得一塌糊涂,现在回来补了) 省赛结束之后,题解pdf就出来了,一看题解,嗯……加一行再求逆矩阵从而得到 ...

  4. XTU 1261 - Roads - [最小割][2017湘潭邀请赛B题(江苏省赛)]

    之前在网上搜了一个下午没搜到这道题的题解,然后同时又对着叉姐写的两行字题解看了一个下午: 虽然基本上已经知道了这题的思路,但愣是因为自己代码实现起来太繁复,外加不确定正确性,没敢码…… 但是一道题肝了 ...

  5. 2017 CCPC 湘潭邀请赛

    都tm快一年了我还没补这套题……再不补怕是要留给退役后乐 Problem A 把$n * (n + 1)$的矩阵补成$(n + 1) * (n + 1)$的,然后高斯消元. Problem B 一看题 ...

  6. 湘潭邀请赛+蓝桥国赛总结暨ACM退役总结

    湘潭邀请赛已经过去三个星期,蓝桥也在上个星期结束,今天也是时候写一下总结了,这应该也是我的退役总结了~ --------------------------------湘潭邀请赛----------- ...

  7. 1250 Super Fast Fourier Transform(湘潭邀请赛 暴力 思维)

    湘潭邀请赛的一题,名字叫"超级FFT"最终暴力就行,还是思维不够灵活,要吸取教训. 由于每组数据总量只有1e5这个级别,和不超过1e6,故先预处理再暴力即可. #include&l ...

  8. 湘潭邀请赛 Hamiltonian Path

    湘潭邀请赛的C题,哈密顿路径,边为有向且给定的所有边起点小于终点,怎么感觉是脑筋急转弯? 以后一定要牢记思维活跃一点,把复杂的事情尽量简单化而不是简单的事情复杂化. #include<cstdi ...

  9. 2017 湘潭邀请赛&JSCPC G&J

    训练的时候对G想了一个假算法..也有很大可能是写错了.. 下来一看别人的G 看起来很奇妙.. 开始把所有的左括号翻成右括号,然后cost*=-1 这样在优先队列中就是最优的 然后for每一段 如果前缀 ...

随机推荐

  1. jquery中each的3种遍历方法

    1.选择器+遍历 $('div').each(function (i){ i就是索引值 this 表示获取遍历每一个dom对象 }); 2.选择器+遍历 $('div').each(function  ...

  2. bin&sbin 命令作用

    最近需要了解sbin与bin的功能,需要整理一下.一下全部为Ubuntu14里面默认安装的.在这里收集一下,转载请注明出处! bin bash shell bunzip2 .bz2文件的解压缩程序. ...

  3. 在每天黄金时刻将数据库中数据获取包装成Excel表

    过程: 1.由Timer对象实现安排指定的任务在指定的时间进行重复的固定的延迟操作 a.设定时间间隔24小时:PERIOD_DAY = 24 * 60 * 60 * 100; b.指定每天执行操作的时 ...

  4. RSA不对称加密和公钥 私钥

    理论上只要有加密的规则 基本都是可以解密的 但是如果解密需要消耗的时间过长 比如1000年 解密过后已经没什么意义了 此时可认为这种算法不能被破解 也就是说此加密可信 MD5 是一种单向操作 加密后不 ...

  5. ImportError: No module named flask.ext.wtf 解决方法

    install pip install flask.ext.wtf

  6. HTML5资源汇总(更新游戏引擎cocos2d-html5)

    我也是现学现用,想了解的可以看看效果,想知道实现的也有源码 http://cocos2d-html5.org Cocos2d-HTML5 API和Cocos2d-x一致,同样的代码可以支持cocos2 ...

  7. Maven归纳

      一.常用功能 1.Maven的中央仓库 https://mvnrepository.com/ 2.添加jar包依赖 1.首先点击pom.xml,然后点击弹出页面中的Dependencies选项,接 ...

  8. JS原型、原型链、构造函数、实例与继承

    https://cloud.tencent.com/developer/article/1408283 https://cloud.tencent.com/developer/article/1195 ...

  9. chrom浏览器-F2使用方法一

    由于F12是前端开发人员的利器,所以我自己也在不断摸索中,查看一些博客和资料后,自己总结了一下来帮助自己理解和记忆,也希望能帮到有需要的小伙伴,嘿嘿! 首先介绍Chrome开发者工具中,调试时使用最多 ...

  10. OpenRead方法打开文件并读取

    实现效果: 知识运用: File类的OpenRead方法 //实现打开现有文件以进行读取 public static FileStream OpenRead(string path) FileStre ...