BC29&&hdoj5170&&hdoj5171&&hdoj5172

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( 1a,b,c,d1000 )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
 

取对数比较

#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,bS ), 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 ( 2n100000,1k1000000000 ). The second line contains n elements  ai  ( 1ai100000 )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
 

容易发现所加的数应为最大的两个数的乘以其斐波那契数列前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("%lld\n",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..rl+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 (  1n,m1000000  ), 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  (  1ain  ) 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 (  1lrn  ), indicating the query range.
 

Output
For each query, if there is a permutation  [1..rl+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
 


先写了个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("YES\n");
			}
			else {
				printf("NO\n");
			}
		}
    }
    return 0;
}


1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看REAdMe.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看REAdMe.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看READme.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 、 1资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看READmE.文件(md如有),本项目仅用作交流学习参考,请切勿用于商业用途。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值