A - A  这题很巧妙啊,前两天刚好做过,而且就在博客里

 Little C Loves 3 I
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Little C loves number «3» very much. He loves all things about it.

Now he has a positive integer nn. He wants to split nn into 33 positive integers a,b,ca,b,c, such that a+b+c=na+b+c=n and none of the 33 integers is a multiple of 33. Help him to find a solution.

Input

A single line containing one integer nn (3≤n≤1093≤n≤109) — the integer Little C has.

Output

Print 33 positive integers a,b,ca,b,c in a single line, such that a+b+c=na+b+c=n and none of them is a multiple of 33.

It can be proved that there is at least one solution. If there are multiple solutions, print any of them.

Examples
input

Copy
  1. 3
output

Copy
  1. 1 1 1
input

Copy
  1. 233
output

Copy
  1. 77 77 79
    被样例困惑了很久,看了题解啧啧,其实这题就是构造
    大致题意:给你一个数n,找到三个数a,b,c,使得a+b+c=n,并且a,b,c都不能是3的倍数
    分析:当n%3=0时,n-2一定不是3的倍数,可以构造为a=1,b=1,c=n-2;当n%3!=0时,n-3一定不是3的倍数,那么可以构造为,a=1,b=2,c=n-3.注意这个构造是任意的,只要满足条件即可
  1. 1 #include<cstdio>
  2. 2 #include<cstring>
  3. 3 #include<algorithm>
  4. 4 using namespace std;
  5. 5 int main()
  6. 6 {
  7. 7 int n;
  8. 8 while(~scanf("%d",&n))
  9. 9 {
  10. 10 if(n%3==0)
  11. 11 printf("1 1 %d\n",n-2);
  12. 12 else
  13. 13 printf("1 2 %d\n",n-3);
  14. 14 }
  15. 15 return 0;
  16. 16 }
B. Cover Points//这题也刚好做过
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

There are nn points on the plane, (x1,y1),(x2,y2),…,(xn,yn)(x1,y1),(x2,y2),…,(xn,yn).

You need to place an isosceles triangle with two sides on the coordinate axis to cover all points (a point is covered if it lies inside the triangle or on the side of the triangle). Calculate the minimum length of the shorter side of the triangle.

Input

First line contains one integer nn (1≤n≤1051≤n≤105).

Each of the next nn lines contains two integers xixi and yiyi (1≤xi,yi≤1091≤xi,yi≤109).

Output

Print the minimum length of the shorter side of the triangle. It can be proved that it's always an integer.

Examples
input

Copy
  1. 3
    1 1
    1 2
    2 1
output

Copy
  1. 3
input

Copy
  1. 4
    1 1
    1 2
    2 1
    2 2
output

Copy
  1. 4
Note

Illustration for the first example:

Illustration for the second example:

题意:唔就是,让你找到一个最小的等腰三角形,使得给出的所有点都包含在等腰三角形里或者等腰三角形边上

分析:  其实就是找给出的点在y轴上截距最大的时候,满足方程y=-x+b,移一下就是,x+y=b,只要找到x+y的最大值即可、

  1. 1 #include<cstdio>
  2. 2 #include<cstring>
  3. 3 #include<algorithm>
  4. 4 #include<cmath>
  5. 5 using namespace std;
  6. 6 int main()
  7. 7 {
  8. 8 int n;
  9. 9 while(~scanf("%d",&n))
  10. 10 {
  11. 11 int a,b,ans=0;
  12. 12 while(n--)
  13. 13 {
  14. 14 scanf("%d %d",&a,&b);
  15. 15 ans=max(a+b,ans);
  16. 16 }
  17. 17 printf("%d\n",ans);
  18. 18 }
  19. 19 return 0;
  20. 20 }

C - C Karen and Morning

Description

Karen is getting ready for a new school day!

It is currently hh:mm, given in a 24-hour format. As you know, Karen loves palindromes, and she believes that it is good luck to wake up when the time is a palindrome.

What is the minimum number of minutes she should sleep, such that, when she wakes up, the time is a palindrome?

Remember that a palindrome is a string that reads the same forwards and backwards. For instance, 05:39 is not a palindrome, because 05:39 backwards is 93:50. On the other hand, 05:50 is a palindrome, because 05:50 backwards is 05:50.

Input

The first and only line of input contains a single string in the format hh:mm (00 ≤ hh ≤ 23, 00 ≤ mm ≤ 59).

Output

Output a single integer on a line by itself, the minimum number of minutes she should sleep, such that, when she wakes up, the time is a palindrome.

Sample Input

Input
  1. 05:39
Output
  1. 11
Input
  1. 13:31
Output
  1. 0
Input
  1. 23:59
Output
  1. 1

Hint

In the first test case, the minimum number of minutes Karen should sleep for is 11. She can wake up at 05:50, when the time is a palindrome.

In the second test case, Karen can wake up immediately, as the current time, 13:31, is already a palindrome.

In the third test case, the minimum number of minutes Karen should sleep for is 1 minute. She can wake up at 00:00, when the time is a palindrome.

题意:这个女孩每到一个回文时间就会醒来,问她最少能睡多长时间。输入的字符串格式一定是hh:xx格式

分析:模拟就好

  1. #include<cstdio>
  2. #include<algorithm>
  3. #include<iostream>
  4. #include<cstring>
  5. #include<cmath>
  6. using namespace std;
  7. int main()
  8. {
  9. char s[];
  10. while(~scanf("%s",s))
  11. {
  12. int a,b;
  13. a=(s[]-'')*+s[]-'';//a是小时
  14. b=(s[]-'')*+s[]-'';//b是分钟
  15. //printf("%d %d",a,b);
  16. int q,w,e,r,j,t,tt,flag=,i;
  17. for(i=a;i<=;i++)//注意只有1-23小时
  18. {
  19. q=i/;
  20. w=i%;
  21. if(i==a)
  22. j=b;
  23. else
  24. j=;
  25. for(;j<=;j++)//只有0-59秒
  26. {
  27.  
  28. e=j/;
  29. r=j%;
  30. if(q==r&&w==e)
  31. {
  32. t=i,tt=j;
  33. flag=;
  34. break;
  35. }
  36. }
  37. if(flag==)
  38. break;
  39. }
  40. // printf("%d %d\n",t,tt);
  41. if(flag==)
  42. {
  43. if(t==a)
  44. printf("%d\n",tt-b);//当在原来的小时形成回文时,只需要减去分钟数就好
  45. else
  46. printf("%d\n",(t-a-)*+-b+tt);//间隔了t-a-1个小时
  47. }
  48. if(flag==&&i==)
  49. printf("%d\n",(-a-)*+-b);
  50. }
  51. return ;
  52. }

D - D

Karen and Coffee
time limit per test

2.5 seconds

memory limit per test

512 megabytes

input

standard input

output

standard output

To stay woke and attentive during classes, Karen needs some coffee!

Karen, a coffee aficionado, wants to know the optimal temperature for brewing the perfect cup of coffee. Indeed, she has spent some time reading several recipe books, including the universally acclaimed "The Art of the Covfefe".

She knows n coffee recipes. The i-th recipe suggests that coffee should be brewed between li and ri degrees, inclusive, to achieve the optimal taste.

Karen thinks that a temperature is admissible if at least k recipes recommend it.

Karen has a rather fickle mind, and so she asks q questions. In each question, given that she only wants to prepare coffee with a temperature between a and b, inclusive, can you tell her how many admissible integer temperatures fall within the range?

Input

The first line of input contains three integers, nk (1 ≤ k ≤ n ≤ 200000), and q (1 ≤ q ≤ 200000), the number of recipes, the minimum number of recipes a certain temperature must be recommended by to be admissible, and the number of questions Karen has, respectively.

The next n lines describe the recipes. Specifically, the i-th line among these contains two integers li and ri (1 ≤ li ≤ ri ≤ 200000), describing that the i-th recipe suggests that the coffee be brewed between li and ri degrees, inclusive.

The next q lines describe the questions. Each of these lines contains a and b, (1 ≤ a ≤ b ≤ 200000), describing that she wants to know the number of admissible integer temperatures between a and b degrees, inclusive.

Output

For each question, output a single integer on a line by itself, the number of admissible integer temperatures between a and b degrees, inclusive.

Examples
input

Copy
  1. 3 2 4
    91 94
    92 97
    97 99
    92 94
    93 97
    95 96
    90 100
output

Copy
  1. 3
    3
    0
    4
input

Copy
  1. 2 1 1
    1 1
    200000 200000
    90 100
output

Copy
  1. 0
Note

In the first test case, Karen knows 3 recipes.

  1. The first one recommends brewing the coffee between 91 and 94 degrees, inclusive.
  2. The second one recommends brewing the coffee between 92 and 97 degrees, inclusive.
  3. The third one recommends brewing the coffee between 97 and 99 degrees, inclusive.

A temperature is admissible if at least 2 recipes recommend it.

She asks 4 questions.

In her first question, she wants to know the number of admissible integer temperatures between 92 and 94 degrees, inclusive. There are 3: 92, 93 and 94 degrees are all admissible.

In her second question, she wants to know the number of admissible integer temperatures between 93 and 97 degrees, inclusive. There are 3: 93, 94 and 97 degrees are all admissible.

In her third question, she wants to know the number of admissible integer temperatures between 95 and 96 degrees, inclusive. There are none.

In her final question, she wants to know the number of admissible integer temperatures between 90 and 100 degrees, inclusive. There are 4: 92, 93, 94 and 97 degrees are all admissible.

In the second test case, Karen knows 2 recipes.

  1. The first one, "wikiHow to make Cold Brew Coffee", recommends brewing the coffee at exactly 1 degree.
  2. The second one, "What good is coffee that isn't brewed at at least 36.3306 times the temperature of the surface of the sun?", recommends brewing the coffee at exactly 200000 degrees.

A temperature is admissible if at least 1 recipe recommends it.

In her first and only question, she wants to know the number of admissible integer temperatures that are actually reasonable. There are none.

题意:有n个食谱,告诉你n段温度适合煮咖啡,如果某个温度被至少k个食谱里的温度包含,则符合条件,你有q次查询,让你求出每次查询中符合条件的温度的数量

分析:看数据量,暴力肯定不行,看代码吧

  1. #include<cstdio>
  2. #include<cstring>
  3. #include<algorithm>
  4. const int m = 2e5;
  5. int main()
  6. {
  7. int n,k,q,a[m];
  8. while(~scanf("%d %d %d",&n,&k,&q))
  9. {
  10. int l,r;
  11. memset(a,,sizeof(a));
  12. for(int i=;i<=n;i++)
  13. {
  14. scanf("%d %d",&l,&r);
  15. a[l]++;
  16. a[r+]--;
  17. }
  18. for(int i=;i<=m;i++)
  19. {
  20. a[i]+=a[i-];
  21. }
  22. for(int i=;i<=m;i++)
  23. {
  24. a[i]=a[i-]+(a[i]>=k);
  25. }
  26. for(int i=;i<=q;i++)
  27. {
  28. scanf("%d %d",&l,&r);
  29. printf("%d\n",a[r]-a[l-]);
  30. }
  31. }
  32. return ;
  33. }

不会解释,贴一个题解的链接https://blog.csdn.net/nka_kun/article/details/73411740

E - E Karen and Game 816c

time limit per test

2 seconds

memory limit per test

512 megabytes

input

standard input

output

standard output

On the way to school, Karen became fixated on the puzzle game on her phone!

The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.

One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column.

To win the level, after all the moves, the number in the cell at the i-th row and j-th column should be equal to gi, j.

Karen is stuck on one level, and wants to know a way to beat this level using the minimum number of moves. Please, help her with this task!

Input

The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the number of rows and the number of columns in the grid, respectively.

The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains gi, j (0 ≤ gi, j ≤ 500).

Output

If there is an error and it is actually not possible to beat the level, output a single integer -1.

Otherwise, on the first line, output a single integer k, the minimum number of moves necessary to beat the level.

The next k lines should each contain one of the following, describing the moves in the order they must be done:

  • row x, (1 ≤ x ≤ n) describing a move of the form "choose the x-th row".
  • col x, (1 ≤ x ≤ m) describing a move of the form "choose the x-th column".

If there are multiple optimal solutions, output any one of them.

Examples
input

Copy
  1. 3 5
    2 2 2 3 2
    0 0 0 1 0
    1 1 1 2 1
output

Copy
  1. 4
    row 1
    row 1
    col 4
    row 3
input

Copy
  1. 3 3
    0 0 0
    0 1 0
    0 0 0
output

Copy
  1. -1
input

Copy
  1. 3 3
    1 1 1
    1 1 1
    1 1 1
output

Copy
  1. 3
    row 1
    row 2
    row 3
Note

In the first test case, Karen has a grid with 3 rows and 5 columns. She can perform the following 4 moves to beat the level:

In the second test case, Karen has a grid with 3 rows and 3 columns. It is clear that it is impossible to beat the level; performing any move will create three 1s on the grid, but it is required to only have one 1 in the center.

In the third test case, Karen has a grid with 3 rows and 3 columns. She can perform the following 3 moves to beat the level:

Note that this is not the only solution; another solution, among others, is col 1, col 2, col 3.

题意:你有一个n×m的矩阵,且全为0,要变成所给出的矩阵,操作要么每行都加1,要么每列都加1,如果可以输出操作的行和列,否则输出-1

分析:这道题其实就是一个模拟的过程,将所给出的矩阵每列或每行减一,看最后的矩阵是否全为0,但要注意两个问题:1:数组大小的问题,一开始数组开太小导致w了好多发;2:当行数小于列数时,先执行消除行的操作;当列数小于行数的时候,先执行消除列的操作。

  1. #include<cstdio>
  2. #include<algorithm>
  3. #include<iostream>
  4. #include<cstring>
  5. #include<cmath>
  6. using namespace std;
  7. int main()
  8. {
  9. int a[][],b[][],c[],d[],aa[],bb[],n,m,e[],f[];
  10. while(~scanf("%d %d",&n,&m))
  11. {
  12. memset(b,,sizeof(b));
  13. for(int i=;i<n;i++)
  14. {
  15. for(int j=;j<m;j++)
  16. {
  17. scanf("%d",&a[i][j]);
  18. }
  19. // printf("%d\n",c[i]);
  20. }//找到每一行最小的那个数
  21. int t=,tt=;
  22. if(n<m)//如果行数小于列数,先消除行
  23. {
  24.  
  25. for(int i=;i<n;i++)
  26. {
  27. for(int j=;j<m;j++)
  28. {
  29. d[j]=a[i][j];
  30. }
  31. sort(d,d+m);
  32. c[i]=d[];
  33. }
  34. for(int i=;i<n;i++)
  35. {
  36. for(int k=;k<c[i];k++)
  37. aa[t++]=i;
  38. // printf("row %d\n",i);
  39.  
  40. for(int j=;j<m;j++)
  41. {
  42. a[i][j]-=c[i];//每一行每个数减去最小的那个数
  43. }
  44. // for(int j=1;j<=m;j++)
  45. // {
  46. // printf("%d ",a[i][j]);
  47. // }
  48. // printf("\n");
  49. }
  50. for(int j=;j<m;j++)
  51. {
  52. for(int i=;i<n;i++)
  53. {
  54. e[i]=a[i][j];
  55. }
  56. sort(e,e+n);
  57. // printf("%d\n",e[0]);
  58. f[j]=e[];//找到每列最小的那个数
  59. }
  60. for(int j=;j<m;j++)
  61. {
  62. for(int k=;k<f[j];k++)
  63. bb[tt++]=j;
  64. // printf("col %d\n",j);
  65. for(int i=;i<n;i++)
  66. {
  67. a[i][j]-=f[j];//每列每个数减去每列最小的那个数
  68. }
  69. }
  70. }
  71. else//如果列数小于行数,先消除列数
  72. {
  73. for(int j=;j<m;j++)
  74. {
  75. for(int i=;i<n;i++)
  76. {
  77. e[i]=a[i][j];
  78. }
  79. sort(e,e+n);
  80. // printf("%d\n",e[0]);
  81. f[j]=e[];//找到每列最小的那个数
  82. }
  83. for(int j=;j<m;j++)
  84. {
  85. for(int k=;k<f[j];k++)
  86. bb[tt++]=j;
  87. // printf("col %d\n",j);
  88. for(int i=;i<n;i++)
  89. {
  90. a[i][j]-=f[j];//每列每个数减去每列最小的那个数
  91. }
  92. }
  93. for(int i=;i<n;i++)
  94. {
  95. for(int j=;j<m;j++)
  96. {
  97. d[j]=a[i][j];
  98. }
  99. sort(d,d+m);
  100. c[i]=d[];
  101. }
  102. for(int i=;i<n;i++)
  103. {
  104. for(int k=;k<c[i];k++)
  105. aa[t++]=i;
  106. // printf("row %d\n",i);
  107.  
  108. for(int j=;j<m;j++)
  109. {
  110. a[i][j]-=c[i];//每一行每个数减去最小的那个数
  111. }
  112. // for(int j=1;j<=m;j++)
  113. // {
  114. // printf("%d ",a[i][j]);
  115. // }
  116. // printf("\n");
  117. }
  118. }
  119. int flag=;
  120. for(int i=;i<n;i++)
  121. {
  122. for(int j=;j<m;j++)
  123. {
  124. if(a[i][j]!=b[i][j])//b为全是0的矩阵
  125. {
  126. flag=;
  127. break;
  128. }
  129. }
  130. }//与全是0的矩阵比较,如果不相等则跳出
  131. if(flag==)
  132. {
  133. printf("-1\n");
  134. }
  135. else
  136. {
  137. printf("%d\n",t+tt);
  138. for(int i=;i<t;i++)
  139. printf("row %d\n",aa[i]+);
  140. for(int i=;i<tt;i++)
  141. printf("col %d\n",bb[i]+);
  142. }
  143. }
  144. return ;
  145. }

2018SDIBT_国庆个人第四场的更多相关文章

  1. 2018SDIBT_国庆个人第七场

    A - Complete the Word(暴力) Description ZS the Coder loves to read the dictionary. He thinks that a wo ...

  2. 2018SDIBT_国庆个人第六场

    A - A codeforces 714A Description Today an outstanding event is going to happen in the forest — hedg ...

  3. 2018SDIBT_国庆个人第五场

    A - ACodeForces 1060A Description Let's call a string a phone number if it has length 11 and fits th ...

  4. 2018SDIBT_国庆个人第三场

    A - A CodeForces - 1042A There are nn benches in the Berland Central park. It is known that aiai peo ...

  5. 2018 HDU多校第四场赛后补题

    2018 HDU多校第四场赛后补题 自己学校出的毒瘤场..吃枣药丸 hdu中的题号是6332 - 6343. K. Expression in Memories 题意: 判断一个简化版的算术表达式是否 ...

  6. 牛客网NOIP赛前集训营-提高组(第四场)游记

    牛客网NOIP赛前集训营-提高组(第四场)游记 动态点分治 题目大意: \(T(t\le10000)\)组询问,求\([l,r]\)中\(k(l,r,k<2^{63})\)的非负整数次幂的数的个 ...

  7. NOI.AC NOIP模拟赛 第四场 补记

    NOI.AC NOIP模拟赛 第四场 补记 子图 题目大意: 一张\(n(n\le5\times10^5)\)个点,\(m(m\le5\times10^5)\)条边的无向图.删去第\(i\)条边需要\ ...

  8. CTF-i春秋网鼎杯第四场部分writeup

    CTF-i春秋网鼎杯第四场部分writeup 因为我们组的比赛是在第四场,所以前两次都是群里扔过来几道题然后做,也不知道什么原因第三场的题目没人发,所以就没做,昨天打了第四场,简直是被虐着打. she ...

  9. 牛客网暑期ACM多校训练营(第四场):A Ternary String(欧拉降幂)

    链接:牛客网暑期ACM多校训练营(第四场):A Ternary String 题意:给出一段数列 s,只包含 0.1.2 三种数.每秒在每个 2 后面会插入一个 1 ,每个 1 后面会插入一个 0,之 ...

随机推荐

  1. k8s服务发现和负载均衡(转)

    原文 http://m635674608.iteye.com/blog/2360095 kubernetes中如何发现服务 如何发现pod提供的服务 如何使用kube-dns发现服务   servic ...

  2. Scrapy实战篇(八)之Scrapy对接selenium爬取京东商城商品数据

    本篇目标:我们以爬取京东商城商品数据为例,展示Scrapy框架对接selenium爬取京东商城商品数据. 背景: 京东商城页面为js动态加载页面,直接使用request请求,无法得到我们想要的商品数据 ...

  3. Android 按下home键,程序在后台运行,在设置中点击程序的启动时,会再次打开启动页的解决办法

    在onCreate()方法中增加如下代码即可: if (!isTaskRoot()) {  finish();  return;  }

  4. CS229 6.8 Neurons Networks implements of PCA ZCA and whitening

    PCA 给定一组二维数据,每列十一组样本,共45个样本点 -6.7644914e-01  -6.3089308e-01  -4.8915202e-01 ... -4.4722050e-01  -7.4 ...

  5. hive中sql使用英文分号

    hql只要遇见分号则认识是语句的EOF,所以对于分号,需要用“\“转义. 例如: insert overwrite table test_json_map select '{"account ...

  6. hive的select重命名字段显示成中文

    select '越南'as `版本`, viplevel, t.dbname, t.account, FightPower from ods t where dt = '2017-03-08' and ...

  7. TableStore:创建SyncClient+getRow读取一行数据

    1.通过控制台或者客户端,在TableStore中新建了实例owlforest,在实例详情中获取到实例访问地址endPoint 2.新建表user,确定主键为userid(Interger)类型,因为 ...

  8. mysql where in形式存储过程如何传递带有单引号的入参

    对于存储过程或者函数,我们通常都有这样的一个需求,传递一个参数,输出一个结果.如:我传递一个账号,返回这个账号所拥有的权限.但是如果这个需求改了,我要传递多个账号,获取这些账号权限,但是账号的个数不限 ...

  9. 函数的嵌套+nonlocal和global关键字(重点)

    1.在函数中声明函数 在内部函数中使用变量的时候, 查找顺序: 先找自己 -> 上一层 -> 上一层..全局 -> 内置 # 函数的互相调用 # def func1(): # pri ...

  10. shell 的有用函数

    1.isNumber 2.命令可用 3.当前用户是root 1.isNumber 判断“字符串”是否是个数字: declare chkNumber= isNumber(){ parameter1=$ ...