总结下这两天做的题目,昨天的题目与图相关的很多,图的题一般就是遇到没见过就gg了,比如那个有向的加强图那个,,沈阳这个有两个推公式的,但是只过了一个。。。number number number这个题明明结束前显示是过了的,服务器崩了我们三条机器都显示是过了的,刚才回去看的时候成了Output Limit Exceeded,剪不断理还乱风水乱流转苍天饶过谁啊,还有一个最长上升子序列的,写的dp一直超时,后来队友给我改了改a了,换了种方法选最长子序列。一直纠结于那么几个题,导致最后相对容易的拿个根本没人去看,没时间了,匆匆忙忙瞎了已一发,没反馈,就gg了,做题不能“恋战”,有的题真是坑死人。

1002

k盏灯  n个屏幕   从n个屏幕中选择k个  求保证这k盏灯颜色不相同的最少的导线

签到题   队友给我讲了讲意思之后,一下就推出(试出)了公式,k+(n-k)k

这个推到的过程大致就是先把边缘的每一个屏幕连接一盏灯。边缘的先先去掉,这样先保证,对于剩下的n-k个屏幕肯定要至少k种颜色,加上试几个数据,公式就来了

1004

给出一个n的序列和一个k   从中拿出k个数来,剩下的数据中,问你是不是非递增或者非递减的数列

刚开始没什么思路,一直纠结于n个里面拿k个,选择太多了,暴力是绝对不行的,大约卡了半个小时,突然灵光一现,既然是要非递增或者非递减,拿就先把递增或者递减的最长序列的个数求出来,这样剩下的数据如果比k大说明就算k个全拿了递增或者递减序列里的数也无济于事,所以只要满足剩下的数据m<=k即可,<的情况就是剩下的拿出来的数据不够,可以从递增或者递减数列的首尾部位借几个,这样就基本可以做了,无奈的就是写了个最长上升和下降之后超时了

1005

题意很简单,从斐波那契数列里选出k个数据来,求其和,问不能组成的最小的数是多少

数据很大,这一看就不能暴力,一度想求出所有的各项,但是发现不现实,不论是递推求,还是公式求,都是不可行的,后来根据强行写出的项,推出最终的公式,ans=F(2*n+1)-1,完美,现在就只剩下解决斐波那契的事了,听到其他的队伍用什么矩阵求各项,到我那个上百度了个模板,提交之后,一度显示是过了,在排名巴黎斗仙是的过了,但是到莫名其妙的现在又成了没过了。

1012

给出一个序列第一行的,还有惩罚值第二行的,你可以移动一些前面的去队伍的后面求最大的子段和,条件是他必须得大于下面其对应的惩罚值的和,中间有其和加起来比下面的小了就得停止了,问你最少移动几下可以得到最大的值

前面根本没看这个题,最后的时候才知道原来相对于其他的来说还算容易的,匆匆茫茫写的那一个代码,答题思路就是按照题意模拟,因为是可以从尾再到头,所以直接在尾部在加上一段,这样直接循环下来,暴力全部走一遍,所以服务器崩了,一直没有回馈,也没再管,刚才到网上看了看有没有什么更好的方法,

最大子段和思想,对两序列的差,和第一行系列,同时进行。

果然,这种思想更好理解了,做法上和我的基本相似,求子段和更优了,找到小鱼0的时候就结束游戏,重开,在此同时,记录下位置即可,这个题只交了一次,运行错误,是因为数组开小了,如果服务器不崩溃,再改进几次说不一定也可以按照我的那种写过,只可惜看的太晚了这个题

1002

cable cable cable

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 0    Accepted Submission(s): 0

Problem Description

Connecting the display screen and signal sources which produce different color signals by cables, then the display screen can show the color of the signal source.Notice that every signal source can only send signals to one display screen each time. 
Now you have M display screens and K different signal sources(K≤M≤232−1). Select K display screens from M display screens, how many cables are needed at least so that **any** K display screens you select can show exactly K different colors.

Input

Multiple cases (no more than 100), for each test case:
there is one line contains two integers M and K.

Output

Output the minimum number of cables N.

Sample Input

 

3 2 20 15

Sample Output

 

4 90

Hint

As the picture is shown, when you select M1 and M2, M1 show the color of K1, and M2 show the color of K2. When you select M3 and M2, M2 show the color of K1 and M3 show the color of K2. When you select M1 and M3, M1 show the color of K1.

#include <iostream>
#include <cstring>
#include <stdio.h>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{long long n,k;while (scanf("%lld%lld",&n,&k)!=EOF){printf("%lld\n",k+(n-k)*k);}
}

1004

array array array

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 0    Accepted Submission(s): 0

Problem Description

One day, Kaitou Kiddo had stolen a priceless diamond ring. But detective Conan blocked Kiddo's path to escape from the museum. But Kiddo didn't want to give it back. So, Kiddo asked Conan a question. If Conan could give a right answer, Kiddo would return the ring to the museum. 
Kiddo: "I have an array A and a number k, if you can choose exactly k elements from A and erase them, then the remaining array is in non-increasing order or non-decreasing order, we say A is a magic array. Now I want you to tell me whether A is a magic array. " Conan: "emmmmm..." Now, Conan seems to be in trouble, can you help him?

Input

The first line contains an integer T indicating the total number of test cases. Each test case starts with two integers n and k in one line, then one line with n integers: A1,A2…An.
1≤T≤20
1≤n≤105
0≤k≤n
1≤Ai≤105

Output

For each test case, please output "A is a magic array." if it is a magic array. Otherwise, output "A is not a magic array." (without quotes).

Sample Input

 

3 4 1 1 4 3 7 5 2 4 1 3 1 2 6 1 1 4 3 5 4 6

Sample Output

 

A is a magic array. A is a magic array. A is not a magic array.

#include<stdio.h>
#include<iostream>
#include<string.h>
#include<cstring>
#include<algorithm>
using namespace std;
int map[1000010];
int dp[1000010];
int dp1[1000010];
int main()
{int temp;int i,j;int t;scanf("%d",&t);int n,k;while(t--){scanf("%d %d",&n,&k);memset(dp,0,sizeof(dp));memset(dp1,0,sizeof(dp1));int max1 = 0;int max2 = 0;int flag = 0;for(i=1;i<=n;i++){scanf("%d",&map[i]);}dp[1] = map[1];int length = 1;for (int i = 2; i <= n; i++){if (map[i] > dp[length])dp[++length] = map[i];else{int p = lower_bound(dp,dp + length,map[i]) - dp;dp[p] = map[i];}}dp1[1] = map[1];int length1 = 1;for (int i = n; i >= 2 ; i--){if (map[i] > dp[length1])dp[++length1] = map[i];else{int p = lower_bound(dp,dp + length1,map[i]) - dp;dp[p] = map[i];}}if (n - length <= k || n - length1 <= k)printf("A is a magic array.\n");elseprintf("A is not a magic array.\n");}return 0;
}

1005

number number number

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 0    Accepted Submission(s): 0

Problem Description

We define a sequence F:

⋅ F0=0,F1=1;
⋅ Fn=Fn−1+Fn−2 (n≥2).

Give you an integer k, if a positive number n can be expressed by
n=Fa1+Fa2+...+Fak where 0≤a1≤a2≤⋯≤ak, this positive number is mjf−good. Otherwise, this positive number is mjf−bad.
Now, give you an integer k, you task is to find the minimal positive mjf−bad number.
The answer may be too large. Please print the answer modulo 998244353.

Input

There are about 500 test cases, end up with EOF.
Each test case includes an integer k which is described above. (1≤k≤109)

Output

For each case, output the minimal mjf−bad number mod 998244353.

Sample Input

 

1

Sample Output

 

4

#include <iostream>//这个代码是未通过的  但是思路就是这样的   根据公式  解决数据范围就基本没有问题了
#include <cstring>
#include <stdio.h>
#include <algorithm>
#include <cmath>
using namespace std;
using namespace std;
const int MOD = 10000;
struct matrix {int m[2][2];
}ans;
matrix base = {1, 1, 1, 0};
matrix multi(matrix a, matrix b) {matrix tmp;for(int i = 0; i < 2; i++) {for(int j = 0; j < 2; j++) {tmp.m[i][j] = 0;for(int k = 0;  k < 2; k++)tmp.m[i][j] = (tmp.m[i][j] + a.m[i][k] * b.m[k][j]) % MOD;}}return tmp;
}
int matrix_pow(matrix a, int n) {ans.m[0][0] = ans.m[1][1] = 1;ans.m[0][1] = ans.m[1][0] = 0;while(n) {if(n & 1) ans = multi(ans, a);a = multi(a, a);n >>= 1;}return ans.m[0][1];
}
int main() {int n;/*while(cin>>n){cout<<n<<endl;}*/while(scanf("%d",&n)){n++;printf("%d\n",(matrix_pow(base,2*n+1)-1)%998244353);}return 0;
}

1012

card card card

Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 0    Accepted Submission(s): 0

Problem Description

As a fan of Doudizhu, WYJ likes collecting playing cards very much. 
One day, MJF takes a stack of cards and talks to him: let's play a game and if you win, you can get all these cards. MJF randomly assigns these cards into n heaps, arranges in a row, and sets a value on each heap, which is called "penalty value".
Before the game starts, WYJ can move the foremost heap to the end any times. 
After that, WYJ takes the heap of cards one by one, each time he needs to move all cards of the current heap to his hands and face them up, then he turns over some cards and the number of cards he turned is equal to the penaltyvalue.
If at one moment, the number of cards he holds which are face-up is less than the penaltyvalue, then the game ends. And WYJ can get all the cards in his hands (both face-up and face-down).
Your task is to help WYJ maximize the number of cards he can get in the end.So he needs to decide how many heaps that he should move to the end before the game starts. Can you help him find the answer?
MJF also guarantees that the sum of all "penalty value" is exactly equal to the number of all cards.

Input

There are about 10 test cases ending up with EOF.
For each test case:
the first line is an integer n (1≤n≤106), denoting n heaps of cards;
next line contains n integers, the ith integer ai (0≤ai≤1000) denoting there are ai cards in ith heap;
then the third line also contains n integers, the ith integer bi (1≤bi≤1000) denoting the "penalty value" of ith heap is bi.

Output

For each test case, print only an integer, denoting the number of piles WYJ needs to move before the game starts. If there are multiple solutions, print the smallest one.

Sample Input

 

5 4 6 2 8 4 1 5 7 9 2

Sample Output

 

4

Hint

For the sample input:+ If WYJ doesn't move the cards pile, when the game starts the state of cards is:4 6 2 8 41 5 7 9 2
WYJ can take the first three piles of cards, and during the process, the number of face-up cards is 4-1+6-5+2-7. Then he can't pay the the "penalty value" of the third pile, the game ends. WYJ will get 12 cards.
+ If WYJ move the first four piles of cards to the end, when the game starts the state of cards is:4 4 6 2 82 1 5 7 9
WYJ can take all the five piles of cards, and during the process, the number of face-up cards is 4-2+4-1+6-5+2-7+8-9. Then he takes all cards, the game ends. WYJ will get 24 cards.It can be improved that the answer is 4.**huge input, please use fastIO.**
 
#include<stdio.h>      //贴个代码吧
             //添上几句注释
typedef long long ll;
const int MAX=1e6+5;
const int INF=0x3f3f3f3f;
int n,a[3*MAX],b[3*MAX];
int main()
{while(~scanf("%d",&n)){int s=0;for(int i=1;i<=n;i++){scanf("%d",&a[i]);a[i+n]=a[i];      //  先构建循环的数列}for(int i=1;i<=n;i++){int x;scanf("%d",&x);b[i]=a[i]-x;      //做差的最大子段和b[i+n]=b[i];}int sum=0,suma=0;int maxa=-INF;int l,r,temp=1;for(int i=1;i<=2*n;i++)  {  suma+=a[i];         //最终需要的最大值sum+=b[i];          //判断的差值  <0则结束       if(suma>maxa){maxa=suma;l=temp;r=i;}if(sum<0){suma=0;sum=0;temp=i+1;if(temp>n+1)break;}}  printf("%d\n",l-1);}return 0;
}

2017 ACM/ICPC Asia Regional Shenyang Online(9.10)相关推荐

  1. [Contest]2017 ACM/ICPC Asia Regional Shenyang Online(01 03 07 09 10 11待补)

    1001 string string string 题意 给定一个字符串$s$,求其中出现$k$次的子串的个数. 题解 后缀自动机. 代码 1002 cable cable cable 题意 给定$M ...

  2. 2017 ACM/ICPC Asia Regional Shenyang Online Ping Ping Ping 树链剖分+树状数组

    原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=6203 题目大意:给出n+1个节点的树( 3<n<10^4),并给出m对点(m<=50 ...

  3. HDU 6194 String String String (后缀数组+线段树, 2017 ACM/ICPC Asia Regional Shenyang Online)

    Problem 求字符串 S 中严格出现 k 次的子串个数 k≥1k\ge 1 |S|≤105|S|\le 10^5 ∑|S|≤2×106\sum |S| \le 2\times 10^6 Idea ...

  4. 2017 ACM/ICPC Asia Regional Shenyang Online array

    原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=6197 题目大意:给出一个序列,删去k个元素是否能构成不上升序列或不下降子序列 (呃,先凑个数吧 二分+ ...

  5. HDU - 5493 Queue 2015 ACM/ICPC Asia Regional Hefei Online(线段树)

    按身高排序,每个人前面最高的人数有上限,如果超出上限说明impossible, 每次考虑最小的人,把他放在在当前的从左往右第k+1个空位 因为要求字典序最小,所以每次k和(上限-k)取min值. 没有 ...

  6. Problem 1002-2017 ACM/ICPC Asia Regional Shenyang Online

    网络赛:2017 ACM/ICPC Asia Regional Shenyang Online 题目来源:cable cable cable Problem Description: Connecti ...

  7. 2015 ACM/ICPC Asia Regional Shenyang Online题解

    以下所有AC题解程序来自"仙客传奇"团队. AC题数:7/13 ABCFGJL A. Traversal AC的C++语言程序: #include <bits/stdc++. ...

  8. 2017 ACM ICPC Asia Regional - Daejeon

    2017 ACM ICPC Asia Regional - Daejeon Problem A Broadcast Stations 题目描述:给出一棵树,每一个点有一个辐射距离\(p_i\)(待确定 ...

  9. 2016 ACM/ICPC Asia Regional Shenyang Online

    I:QSC and Master 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5900 题意: 给出n对数keyi,vali表示当前这对数的键值和权值 ...

最新文章

  1. 比特币大涨,如何辨别牛市是否真正到来?
  2. Java程序员需要熟悉的库
  3. linux uvc协议_linux使用UVC采集数据
  4. 拖放获取文件信息的bat代码
  5. SpringCloud学习笔记028---在SpringBoot中整合多数据源_实战项目
  6. android没有蓝牙设备,【Android】没有触发LeScanCallback导致无法搜索到蓝牙设备
  7. 自由软件之父回归 FSF,遭 1933 人、21 家组织联名抵制!
  8. 计算机组成定时方式,2019考研408计算机组成原理知识:总线操作和定时
  9. 2020最常用的8个代码编辑器推荐
  10. debian 配置linuxptp 软件时间戳
  11. kafka传数据到Flink存储到mysql之Flink使用SQL语句聚合数据流(设置时间窗口,EventTime)...
  12. Scratch的广播与消息
  13. stm32使用AD采样需要注意的一些小问题
  14. 学而思编程python拓展版_学而思网校【2019-寒】少儿编程直播班-scratch Level 1上(零基础)...
  15. 适合糖友增强饱腹感的一些主食
  16. Android广告SDK的Package
  17. linux下view如何修改字符串,Linux下view命令的使用
  18. android动画送礼物,Android开发仿映客送礼物效果
  19. 登录失败提示账号或密码错误!
  20. 2020形式化方法复习笔记

热门文章

  1. 【程序人生】改不完的bug,写不完的需求,爬不完的坑
  2. CocoaPods的时代
  3. 一个不务正业的前端攻城狮
  4. 攻防世界 Misc高手进阶区 2分题 倒立屋
  5. C++11 - std::bind简要介绍以及可绑定函数的几种形式总结
  6. 【Android Studio学习】第二篇、APP实现画简易的波形图
  7. markdown 流程图语法
  8. 从零单刷Leetcode(JAVA描述)——46. 全排列
  9. 【神经网络本质是多项式回归】Jeff Dean等论文发现逻辑回归和深度学习一样好
  10. 无线WIFI网络密码破解程序