欧美1区2区3区激情无套,两个女人互添下身视频在线观看,久久av无码精品人妻系列,久久精品噜噜噜成人,末发育娇小性色xxxx

榮耀機(jī)試20220816

滿分600,三道編程,和華子一樣。

第一題(100%通過):
日期處理題,輸入是xxxx年xx月第xx周的周x,要求轉(zhuǎn)換為xxxx-xx-xx標(biāo)準(zhǔn)格式。從2000-01-01開始,要考慮閏年,要考慮非法輸入(比如2018年01月第08周的周1,這種肯定就是不對的)

//
// Created by LJ on 2022/8/16.
//

#include <iostream>
#include <vector>
#include <map>
#include <stdio.h>
using namespace std;

vector<int> monthDays{0,31,28,31,30,31,30,31,31,30,31,30,31};
vector<int> weekdayFromStart{5,6,7,1,2,3,4};

int main(){
    // 處理輸入
    int year, month, week, weekday;
    cin >> year >> month >> week >> weekday;
    // 數(shù)據(jù)處理
    // year:month:01 到2000-01-01過了多少天
    int days = 0;
    days += (year-2000) * 365;
    // 閏年要考慮進(jìn)去
    for(int y = 2000; y < year; ++y){
        if(y % 4 == 0 && y % 100 != 0){ days++; }
        else if(y % 400 == 0){ days++; }
    }
    // 算月的時間
    for(int m = 1; m < month; ++m){
        days += monthDays[m];
    }
    // 當(dāng)年如果是閏年,并且月份大于2月,需要多加一天
    if(month > 2 && ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)){ days++; }
    // 不考慮第幾個周的周幾,總的時間已經(jīng)算好了
    ++days;
//     cout << days << endl; // 打印測試一下
    // days / 7 得到余數(shù),表示到y(tǒng)ear:month:01是星期幾
    int res = days % 7;
//     cout << "res: " << res << endl;
    int dayFromYearMonth01 = weekdayFromStart[res];
//     cout << "周" << dayFromYearMonth01 << endl;
    // 準(zhǔn)備輸出
    int firstWeekdaysCnt = 7-dayFromYearMonth01+1;
    if(week == 1){
        // 第一個周,需要判斷指定的日期,是否在year:month:01之前
        if(weekday < dayFromYearMonth01){ cout << 0 << endl;}
        else{ printf("%04d-%02d-%02d", year, month, weekday-dayFromYearMonth01+1);}
    }
    else{
        int resWeekdaysCnt = (week-2)*7 + firstWeekdaysCnt + weekday;
        // 計算得到的總?cè)掌?,如果超過了當(dāng)月的總天數(shù),也是錯誤的非法數(shù)據(jù)
        if(resWeekdaysCnt > monthDays[month]){
            // 還要判斷是不是閏年
            if(month == 2 && (year % 4 == 0 && year % 100 != 0) || year % 400 == 0){
                if(resWeekdaysCnt == 29){
                    printf("%04d-%02d-%02d", year, month, resWeekdaysCnt);
                }
            }
            else cout << 0 << endl;
        }
        else{
            printf("%04d-%02d-%02d", year, month, resWeekdaysCnt);
        }
    }

    return 0;
}
/**
* 分析題意:
 * 將【某年某月第幾個周幾】轉(zhuǎn)換為【公歷日期】
 *    - 存在非法數(shù)據(jù)
 *    - 每月的第一周和最后一周一般都不完整
 *    - 還要考慮閏年的影響
 *    - 起始時間為2000-01-01,時間為周六
*/

第二題:買賣物品(100%通過)
簡單的離譜。給了兩個數(shù)組,分別代表商品的***和售賣價,要求最后得到的利潤。直接遍歷。。。

//
// Created by LJ on 2022/8/16.
//
#include <iostream>
#include <vector>
#include <string>
using namespace std;
void s2vec(const string &s1, vector<int> &m){
    int num = 0;
    for(char ch : s1){
        if(ch == ','){
            m.push_back(num);
            num = 0;
        }
        else{
            num *= 10;
            num += ch-'0';
        }
    }
    m.push_back(num);
}
int main(){
    // 輸入數(shù)據(jù)處理
    string s1, s2;
    cin >> s1 >> s2;
    int k;
    cin >> k;
    vector<int> m, n;
    s2vec(s1, m);
    s2vec(s2, n);
    // 打印測試一下
//     for(int i : m){ cout << i << " "; }
//     cout << endl;
//     for(int i : n){ cout << i << " "; }
//     cout << endl;
    // 解題
    for(int i = 0; i < m.size(); ++i){
        if(m[i] < n[i]){
            k += n[i]-m[i];
        }
    }
    // 輸出
    cout << k << endl;
    return 0;
}

第三題(80%通過):
題意:小明要練習(xí)超級左旋技巧,輸入數(shù)據(jù)為多組一維數(shù)組,對于第i天的小明,如果前面天數(shù)的練習(xí)中,失誤次數(shù)小于,技巧值就要加1,否則就減1。相等的話不變。要求輸出每一組數(shù)據(jù)的最大技能獲得值,以及最后的技能獲得值。(題目有點繞,然后沒時間去想優(yōu)化了。

//
// Created by LJ on 2022/8/16.
//
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main(){
    // 處理輸入數(shù)據(jù)
    int T;
    cin >> T;
    vector<vector<int>> trains;
    for(int i = 0; i < T; ++i){
        int n;
        cin >> n;
        vector<int> tmp;
        for(int j = 0; j < n; ++j){
            int a;
            cin >> a;
            tmp.push_back(a);
        }
        trains.push_back(tmp);
    }
    // 打印輸出
//    for(auto &it : trains){
//        for(auto i :it){
//            cout << i << " ";
//        }
//        cout << endl;
//    }
    // 暴力解題
    vector<vector<int>> ans;
    for(auto &it : trains){
        int maxValue = 0;
        int currValue = 0;
        for(int i = 1; i < it.size(); ++i){
            // 應(yīng)該嘗試用空間換時間,才能跑完所有案例
            for(int j = 0; j < i; ++j){
                if(it[i] > it[j]){ ++currValue; }
                else if(it[i] < it[j]){ --currValue; }
            }
            maxValue = max(maxValue, currValue);
        }
        ans.push_back({maxValue, currValue});
    }
    // 輸出
    for(auto &it : ans){
        for(int i : it){ cout << i << " "; }
        cout << endl;
    }
    return 0;
}
#榮耀筆試##榮耀#
全部評論
到現(xiàn)在沒收到機(jī)試…估計我沒了??
1 回復(fù) 分享
發(fā)布于 2022-08-20 12:22 河北
借個樓,謝謝。有興趣投榮耀但還在觀望的同學(xué)們,抓緊時間沖啦,機(jī)會不等人,我可以內(nèi)推。榮耀honor招聘官網(wǎng)https://www.hihonor.com/cn/career/ 內(nèi)推碼:yuhvad
1 回復(fù) 分享
發(fā)布于 2022-08-20 02:16 廣東
line = await readline() let total = +line let res = [] while (total--) { line = await readline() let days = +line line = await readline() let nums = line.split(' ').map(Number) let count = 0 let max = -Infinity let sorted = [] for (let i = 0; i < nums.length; i++) { let index = sorted.indexOf(nums[i]) if (index == -1) { sorted.push(nums[i]) if (sorted.length == 1) { max = count continue } let j = sorted.length - 1 for (; j > 0; j--) { if (sorted[j] < sorted[j - 1]) { [sorted[j], sorted[j - 1]] = [sorted[j - 1], sorted[j]]; } else { break } } count = count + j - (sorted.length - 1 - j) } else { count = count + index - (sorted.length - 1 - index) } if (count > max) { max = count } } let str = max + ' ' + count res.push(str) } res.forEach((item) => console.log(item))
點贊 回復(fù) 分享
發(fā)布于 2023-07-14 18:04 廣東
請問能用matlab嗎
點贊 回復(fù) 分享
發(fā)布于 2022-08-20 10:52 上海
請問,前后端機(jī)試題一樣嗎
點贊 回復(fù) 分享
發(fā)布于 2022-08-17 09:25 廣東
發(fā)一個投票吧,請各位在下面點贊投下票,醬油給我點贊
點贊 回復(fù) 分享
發(fā)布于 2022-08-17 00:10 陜西
第三題樹狀數(shù)組
點贊 回復(fù) 分享
發(fā)布于 2022-08-16 21:17
第二題不用考慮買不起的情況嗎?
點贊 回復(fù) 分享
發(fā)布于 2022-08-16 20:43
第三題思路一樣,不過java就通過了20%難受
點贊 回復(fù) 分享
發(fā)布于 2022-08-16 20:40

相關(guān)推薦

點贊 評論 收藏
分享
評論
1
46
分享

創(chuàng)作者周榜

更多
??途W(wǎng)
??推髽I(yè)服務(wù)