zoukankan      html  css  js  c++  java
  • 51nod1024(math+set)

    题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1024

    题意:中文题诶~

    思路:要是能求出a^b的值来就好了。。a<=100, b<=100,直接求显然是相当麻烦的;

    高中数学学过对数,对于指数问题我们可以考虑一下是否可以用对数化简,这道题显然是可以的;因为如果 logN(a)=logN(b),那么a=b(log是单射函数啦);

    所以我们可以给矩阵里的所有元素取相同底数的对数然后再来比较,这里我们可以取N=2,可以减一些误差。。。

    log2(a^b)=b*log2(a), 这样就不用进行很大的幂运算了啦。。。

    代码:

     1 #include <bits/stdc++.h>
     2 #define MAXN 110
     3 using namespace std;
     4 
     5 int main(void){
     6     int m, n, a, b;
     7     set<double> st;
     8     cin >> m >> n >> a >> b;
     9     for(int i=a; i<a+n; i++){
    10         for(int j=b; j<b+m; j++){
    11             st.insert(1.0*j*log2(i));
    12         }
    13     }
    14     cout << st.size() << endl;
    15     return 0;
    16 }
  • 相关阅读:
    重装Win10系统的非常简单的操作教程
    Python
    Delphi
    Libs
    Windows Server
    Windows Server
    Delphi
    Delphi
    Delphi
    Delphi
  • 原文地址:https://www.cnblogs.com/geloutingyu/p/6280220.html
Copyright © 2011-2022 走看看