我是靠谱客的博主 粗犷大山,最近开发中收集的这篇文章主要介绍BC29&&hdoj5170&&hdoj5171&&hdoj5172 GTY's math problem GTY's birthday gift GTY's gay friends,觉得挺不错的,现在分享给大家,希望可以做个参考。
概述
GTY's math problem
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1907 Accepted Submission(s): 719
Problem Description
GTY is a GodBull who will get an Au in NOI . To have more time to learn algorithm knowledge, he never does his math homework. His math teacher is very unhappy for that, but she can't do anything because GTY can always get a good mark in math exams. One day, the math teacher asked GTY to answer a question. There are four numbers on the blackboard -
a,b,c,d
. The math teacher wants GTY to compare
ab
with
cd
. Because GTY never does his homework, he can't figure out this problem! If GTY can't answer this question correctly, he will have to do his homework. So help him!
Input
Multi test cases (about 5000). Every case contains four integers a,b,c,d(
1≤a,b,c,d≤1000
)separated by spaces. Please process to the end of file.
Output
For each case , if
ab>cd
, print '>'. if
ab<cd
, print '<'. if
ab=cd
, print '='.
Sample Input
2 1 1 2 2 4 4 2 10 10 9 11
Sample Output
> = <
Source
BestCoder Round #29
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<list>
#include<vector>
#define eps 1e-8
using namespace std;
const int maxn=10010;
int main()
{
double a,b,c,d;
while(scanf("%lf%lf%lf%lf",&a,&b,&c,&d)!=EOF){
double l=b*log(a);
double r=d*log(c);
if(fabs(r-l)<eps){
printf("=n");
}
else if(r-l>eps){
printf("<n");
}
else {
printf(">n");
}
}
return 0;
}
GTY's birthday gift
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1190 Accepted Submission(s): 458
Problem Description
FFZ's birthday is coming. GTY wants to give a gift to ZZF. He asked his gay friends what he should give to ZZF. One of them said, 'Nothing is more interesting than a number multiset.' So GTY decided to make a multiset for ZZF. Multiset can contain elements with same values. Because GTY wants to finish the gift as soon as possible, he will use JURUO magic. It allows him to choose two numbers a and b(
a,b∈S
), and add
a+b
to the multiset. GTY can use the magic for k times, and he wants the sum of the multiset is maximum, because the larger the sum is, the happier FFZ will be. You need to help him calculate the maximum sum of the multiset.
Input
Multi test cases (about 3) . The first line contains two integers n and k (
2≤n≤100000,1≤k≤1000000000
). The second line contains n elements
ai
(
1≤ai≤100000
)separated by spaces , indicating the multiset S .
Output
For each case , print the maximum sum of the multiset (
mod 10000007
).
Sample Input
3 2 3 6 2
Sample Output
35
Source
BestCoder Round #29
容易发现所加的数应为最大的两个数的乘以其斐波那契数列前k项和由于k=1000000000考虑矩阵快速幂求前n项和既有构造矩阵
1 1 1 s[n-1]
0 1 1 * f[n-1]
0 1 0 f[n-2]
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<list>
#include<vector>
#define MOD 10000007
using namespace std;
const int maxn=100010;
long long ans[3][3];
long long mat[3][3];
long long num[maxn];
void Mulit(long long A[3][3],long long B[3][3]){
long long D[3][3]={0};
for(int i=0;i<3;++i){
for(int k=0;k<3;++k){
if(A[i][k]){
for(int j=0;j<3;++j){
D[i][j]=(D[i][j]+A[i][k]*B[k][j]%MOD)%MOD;
}
}
}
}
for(int i=0;i<3;++i){
for(int j=0;j<3;++j){
A[i][j]=D[i][j];
}
}
}
void Matrix(long long A[3][3],int n){
for(int i=0;i<3;++i){
for(int j=0;j<3;++j){
ans[i][j]=(i==j);
}
}
while(n){
if(n&1)Mulit(ans,A);
Mulit(A,A);
n>>=1;
}
}
int main()
{
int n,k,i,j;
while(scanf("%d%d",&n,&k)!=EOF){
long long sum=0;
for(i=1;i<=n;++i){
scanf("%lld",&num[i]);
sum=(sum+num[i])%MOD;
}
sort(num+1,num+n+1);
mat[0][0]=1;mat[0][1]=1;mat[0][2]=1;
mat[1][0]=0;mat[1][1]=1;mat[1][2]=1;
mat[2][0]=0;mat[2][1]=1;mat[2][2]=0;
Matrix(mat,k);
sum=(sum+num[n-1]*ans[0][2]%MOD)%MOD;
sum=(sum+num[n]*ans[0][1]%MOD)%MOD;
printf("%lldn",sum);
}
return 0;
}
GTY's gay friends
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1296 Accepted Submission(s): 332
Problem Description
GTY has
n
gay friends. To manage them conveniently, every morning he ordered all his gay friends to stand in a line. Every gay friend has a characteristic value
ai
, to express how manly or how girlish he is. You, as GTY's assistant, have to answer GTY's queries. In each of GTY's queries, GTY will give you a range
[l,r]
. Because of GTY's strange hobbies, he wants there is a permutation
[1..r−l+1]
in
[l,r]
. You need to let him know if there is such a permutation or not.
Input
Multi test cases (about 3) . The first line contains two integers n and m (
1≤n,m≤1000000
), indicating the number of GTY's gay friends and the number of GTY's queries. the second line contains n numbers seperated by spaces. The
ith
number
ai
(
1≤ai≤n
) indicates GTY's
ith
gay friend's characteristic value. The next m lines describe GTY's queries. In each line there are two numbers l and r seperated by spaces (
1≤l≤r≤n
), indicating the query range.
Output
For each query, if there is a permutation
[1..r−l+1]
in
[l,r]
, print 'YES', else print 'NO'.
Sample Input
8 5 2 1 3 4 5 2 3 1 1 3 1 1 2 2 4 8 1 5 3 2 1 1 1 1 1 1 2
Sample Output
YES NO YES YES YES YES NO
Source
BestCoder Round #29
先写了个RMQ 超内存然后线段树超时。。。。无奈按照标称所说的建立hash表
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<list>
#include<queue>
#include<vector>
#include<map>
using namespace std;
const int maxn=1000010;
long long num[maxn];
long long array[maxn];
long long Hash[maxn];
void init(){
for(int i=1;i<=1000000;++i){
Hash[i]=1000007+rand()%1000000;
}
for(int i=1;i<=1000000;++i){
array[i]=array[i-1]+i*Hash[i];
}
}
int main()
{
init();
int i,j,n,m;
while(scanf("%d%d",&n,&m)!=EOF){
for(i=1;i<=n;++i){
scanf("%lld",&num[i]);
num[i]=num[i-1]+num[i]*Hash[num[i]];
}
long long l,r;
while(m--){
scanf("%lld%lld",&l,&r);
if(array[r-l+1]==num[r]-num[l-1]){
printf("YESn");
}
else {
printf("NOn");
}
}
}
return 0;
}
最后
以上就是粗犷大山为你收集整理的BC29&&hdoj5170&&hdoj5171&&hdoj5172 GTY's math problem GTY's birthday gift GTY's gay friends的全部内容,希望文章能够帮你解决BC29&&hdoj5170&&hdoj5171&&hdoj5172 GTY's math problem GTY's birthday gift GTY's gay friends所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复