头像

苏洵的小弟




离线:8天前


最近来访(5)
用户头像
FJ_EYoungOneC
用户头像
Royal
用户头像
用户头像
huangbq


怎么看自己做了哪些题目




题目描述

blablabla

样例

blablabla

算法1

(暴力枚举) $O(n^2)$

blablabla

时间复杂度

参考文献

C++ 代码

blablabla

算法2

(暴力枚举) $O(n^2)$

blablabla

时间复杂度

参考文献

C++ 代码

#include<iostream>
#include <cmath>

using namespace std;

int main(){
    string a,b,c;
    cin>>a>>b>>c;
    if (a == "vertebrado") {
        if (b=="ave"){
            if (c =="carnivoro")::printf("aguia");
            else{ ::printf("pomba");}
        }else{
            if (c=="onivoro")::printf("homem");
            else{ ::printf("vaca");}
        }
    }else{
        if (b=="inseto"){
            if (c =="hematofago")::printf("pulga");
            else{ ::printf("lagarta");}
        }else{
            if (c=="hematofago")::printf("sanguessuga");
            else{ ::printf("minhoca");}
        }
    }
    return 0;
}





题目描述

blablabla

样例

blablabla

算法1

(暴力枚举) $O(n^2)$

blablabla

时间复杂度

参考文献

C++ 代码

blablabla

算法2

(暴力枚举) $O(n^2)$

blablabla

时间复杂度

参考文献

C++ 代码

blablabla

include[HTML_REMOVED]

using namespace std;

int main()
{
int a,b;
int c[7] = {100,50,20,10,5,2,1};
cin >> a;
cout<< a <<endl;
for (int i = 0; i < 7 ; ++i) {
b = a/c[i];
a = a%c[i];
cout<< b << ” nota(s) de R$ “<< c[i]<<”,00”<<endl;
}
return 0;
}




苏洵的小弟
2022-02-17 20:35
class Solution {
public:
    int maxArea(vector<int>& height) {
        int res = 0 ;
        for( int i = 0 , j = height.size()-1 ; i < j ;){
            res = max( res, min( height[i] , height[j])*( j - i ));
            if(height[i] > height[j]) j--;
            else i++;
        }
        return res;
    }
};


活动打卡代码 LeetCode 9. 回文数

苏洵的小弟
2022-02-17 14:27
class Solution {
public:
    bool isPalindrome(int x) {
        if(x < 0 || x && x % 10 == 0) return false;
        int s = 0;
        while(s <= x){
            s = s *10 + x % 10;
            if(s == x || s == x / 10 ) return true;
            x /= 10;
        }
        return false;
    }
};


活动打卡代码 LeetCode 7. 整数反转

苏洵的小弟
2022-02-16 19:33
class Solution {
public:
    int reverse(int x) {
        int r = 0;
        while(x){
            if(r > 0 && r > (INT_MAX -x%10)/10 ) return 0;
            if(r < 0 && r < (INT_MIN -x%10)/10 ) return 0;
            r = r *10 + x%10;
            x /=10;
        } 
        return r;
    }
};


活动打卡代码 LeetCode 6. Z 字形变换

苏洵的小弟
2022-02-16 19:33
class Solution {
public:
    string convert(string s, int numRows) {
        string res;
        if (numRows == 1) return s;
        for (int j = 0; j < numRows; j ++ )
        {
            if (j == 0 || j == numRows - 1)
            {
                for (int i = j; i < s.size(); i += (numRows-1) * 2)
                    res += s[i];
            }
            else
            {
                for (int k = j, i = numRows * 2 - 1 - j - 1;
                        i < s.size() || k < s.size();
                        i += (numRows - 1) * 2, k += (numRows - 1) * 2)
                {
                    if (k < s.size()) res += s[k];
                    if (i < s.size()) res += s[i];
                }
            }
        }
        return res;
    }
};





苏洵的小弟
2022-02-15 19:31
class Solution {
public:
    string defangIPaddr(string address) {
        string res;
        for(int i = 0 ; i <address.size() ; i ++){
            if(address[i] != '.'){
                res+=address[i];
            }else{res+="[.]";}
        }
        return res;
    }
};


活动打卡代码 LeetCode 5. 最长回文子串

苏洵的小弟
2022-02-15 19:21
class Solution {
public:
    string longestPalindrome(string s) {
        string res;
        for(int i = 0 ; i < s.size() ; i++){
            int l = i - 1,r = i +  1 ;
            while (l >= 0 && r <s.size()&& s[l]== s[r]) l -- ,r ++;
            if(res.size()<r-l-1) res = s.substr(l + 1,r - l - 1);

            l = i , r = i +1 ;
            while(l >= 0&& r<s.size() && s[l] == s[r] ) l --,r++;
            if(res.size()<r-l-1) res = s.substr(l + 1,r - l - 1);
        }
        return res;
    }
};


活动打卡代码 LeetCode 2. 两数相加

苏洵的小弟
2022-02-15 17:52

class Solution {
public:
    ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
        ListNode *res = new ListNode(-1);
        ListNode *cur = res;
        int carry = 0 ;
        while(l1||l2){
            int n1 = l1 ? l1->val : 0 ;
            int n2 = l2 ? l2->val : 0 ;
            int sum = n1 + n2 + carry;
            carry = sum / 10 ;
            cur ->next = new ListNode(sum %10);
            cur = cur ->next;
            if(l1) l1 = l1->next;
            if(l2) l2 = l2->next;

        }
        if(carry) cur->next = new ListNode(1);
        return res->next;
    }
};