当前位置: 首页 > news >正文

怎样做公司网站推广上海网站设计公司有哪些

怎样做公司网站推广,上海网站设计公司有哪些,代码生成器软件,微商城网站建设服务1185. 一周中的第几天 给你一个日期#xff0c;请你设计一个算法来判断它是对应一周中的哪一天。 输入为三个整数#xff1a;day、month 和 year#xff0c;分别表示日、月、年。 您返回的结果必须是这几个值中的一个 {“Sunday”, “Monday”, “Tuesday”, “Wednesday…1185. 一周中的第几天 给你一个日期请你设计一个算法来判断它是对应一周中的哪一天。 输入为三个整数day、month 和 year分别表示日、月、年。 您返回的结果必须是这几个值中的一个 {“Sunday”, “Monday”, “Tuesday”, “Wednesday”, “Thursday”, “Friday”, “Saturday”}。 示例 1 输入day 31, month 8, year 2019 输出“Saturday” 示例 2 输入day 18, month 7, year 1999 输出“Sunday” 示例 3 输入day 15, month 8, year 1993 输出“Sunday” 提示 给出的日期一定是在 1971 到 2100 年之间的有效日期。 年底的简单模拟题 class Solution { public:string dayOfTheWeek(int day, int month, int year) {// 1971年1月1日是星期五int knownDayOfWeek 5;// 月份天数表注意2月份需要根据闰年来确定天数int daysInMonth[] {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};if ((year % 4 0 year % 100 ! 0) || (year % 400 0)) {daysInMonth[2] 29; // 闰年2月有29天}// 累计天数int totalDays 0;for (int y 1971; y year; y) {totalDays 365;if ((y % 4 0 y % 100 ! 0) || (y % 400 0)) {totalDays; // 闰年多加一天}}for (int m 1; m month; m) {totalDays daysInMonth[m];}totalDays day - 1; // 减去1因为日期从1开始// 计算星期几int dayOfWeek (knownDayOfWeek totalDays) % 7;// 星期几的映射std::string daysOfWeek[] {Friday, Saturday, Sunday, Monday,Tuesday, Wednesday, Thursday};return daysOfWeek[dayOfWeek];} };1154. 一年中的第几天 给你一个字符串 date 按 YYYY-MM-DD 格式表示一个 现行公元纪年法 日期。返回该日期是当年的第几天。 示例 1 输入date “2019-01-09” 输出9 解释给定日期是2019年的第九天。 示例 2 输入date “2019-02-10” 输出41 提示 date.length 10 date[4] date[7] ‘-’其他的 date[i] 都是数字 date 表示的范围从 1900 年 1 月 1 日至 2019 年 12 月 31 日 class Solution { public:int dayOfYear(string date) {int year stoi(date.substr(0, 4));int month stoi(date.substr(5, 2));int day stoi(date.substr(8, 2));int amount[] {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};if (year % 400 0 || (year % 4 0 year % 100 ! 0)) {amount[1];}int ans 0;for (int i 0; i month - 1; i) {ans amount[i];}return ans day;} };该题同样是模拟掌握stoi的使用即可当然也可以前缀和解决。 1599. 经营摩天轮的最大利润 你正在经营一座摩天轮该摩天轮共有 4 个座舱 每个座舱 最多可以容纳 4 位游客 。你可以 逆时针 轮转座舱但每次轮转都需要支付一定的运行成本 runningCost 。摩天轮每次轮转都恰好转动 1 / 4 周。 给你一个长度为 n 的数组 customers customers[i] 是在第 i 次轮转下标从 0 开始之前到达的新游客的数量。这也意味着你必须在新游客到来前轮转 i 次。每位游客在登上离地面最近的座舱前都会支付登舱成本 boardingCost 一旦该座舱再次抵达地面他们就会离开座舱结束游玩。 你可以随时停下摩天轮即便是 在服务所有游客之前 。如果你决定停止运营摩天轮为了保证所有游客安全着陆将免费进行所有后续轮转 。注意如果有超过 4 位游客在等摩天轮那么只有 4 位游客可以登上摩天轮其余的需要等待 下一次轮转 。 返回最大化利润所需执行的 最小轮转次数 。 如果不存在利润为正的方案则返回 -1 。 示例 1 输入customers [8,3], boardingCost 5, runningCost 6 输出3 解释座舱上标注的数字是该座舱的当前游客数。 8 位游客抵达4 位登舱4 位等待下一舱摩天轮轮转。当前利润为 4 * $5 - 1 * $6 $14 。3 位游客抵达4 位在等待的游客登舱其他 3 位等待摩天轮轮转。当前利润为 8 * $5 - 2 * $6 $28 。最后 3 位游客登舱摩天轮轮转。当前利润为 11 * $5 - 3 * $6 $37 。 轮转 3 次得到最大利润最大利润为 $37 。 示例 2 输入customers [10,9,6], boardingCost 6, runningCost 4 输出7 解释 10 位游客抵达4 位登舱6 位等待下一舱摩天轮轮转。当前利润为 4 * $6 - 1 * $4 $20 。9 位游客抵达4 位登舱11 位等待2 位是先前就在等待的9 位新加入等待的摩天轮轮转。当前利润为 8 * $6 - 2 * $4 $40 。最后 6 位游客抵达4 位登舱13 位等待摩天轮轮转。当前利润为 12 * $6 - 3 * $4 $60 。4 位登舱9 位等待摩天轮轮转。当前利润为 * $6 - 4 * $4 $80 。4 位登舱5 位等待摩天轮轮转。当前利润为 20 * $6 - 5 * $4 $100 。4 位登舱1 位等待摩天轮轮转。当前利润为 24 * $6 - 6 * $4 $120 。1 位登舱摩天轮轮转。当前利润为 25 * $6 - 7 * $4 $122 。 轮转 7 次得到最大利润最大利润为$122 。 示例 3 输入customers [3,4,0,5,1], boardingCost 1, runningCost 92 输出-1 解释 3 位游客抵达3 位登舱0 位等待摩天轮轮转。当前利润为 3 * $1 - 1 * $92 -$89 。4 位游客抵达4 位登舱0 位等待摩天轮轮转。当前利润为 7 * $1 - 2 * $92 -$177 。0 位游客抵达0 位登舱0 位等待摩天轮轮转。当前利润为 7 * $1 - 3 * $92 -$269 。5 位游客抵达4 位登舱1 位等待摩天轮轮转。当前利润为 11 * $1 - 4 * $92 -$357 。1 位游客抵达2 位登舱0 位等待摩天轮轮转。当前利润为 13 * $1 - 5 * $92 -$447 。 利润永不为正所以返回 -1 。 提示 n customers.length 1 n 105 0 customers[i] 50 1 boardingCost, runningCost 100 题目虽然长但是逻辑很清晰我们直接模拟计算即可 class Solution { public:int minOperationsMaxProfit(vectorint customers, int boardingCost, int runningCost) {int ans -1;int mx 0, t 0;int wait 0, i 0;while (wait || i customers.size()) {wait i customers.size() ? customers[i] : 0;int up min(4, wait);wait - up;i;t up * boardingCost - runningCost;if (t mx) {mx t;ans i;}}return ans;} }; 466. 统计重复个数hard 这个题实在是不会做加上这两周在准备考试草草看了题解就去复习了等放假后细补: class Solution { public:int getMaxRepetitions(string s1, int n1, string s2, int n2) {if (n1 0){return 0;}int ns1 s1.size();int ns2 s2.size();// s1和s2重复出现的数量int s1cnt 0;int s2cnt 0;// s2里的编号 i2int i2 0;// i 映射到 s1cnt, s2cntunordered_mapint, pairint,int i2cnt;while (true){s1cnt;// 遍历一个s1for (char c : s1){if (c s2[i2]){i2;// 完成一个s2的匹配if (i2 ns2){s2cnt;// 要重新计数回到s2的编号0i2 0;}}}// 发现s1的n1都用完了依然找不到, 直接计算返回if (s1cnt n1){return s2cnt / n2;}// 找到之前循环的i2那么就可以循环计算了if (i2cnt.find(i2) ! i2cnt.end()){int s1cntPre i2cnt[i2].first;int s2cntPre i2cnt[i2].second;// 开始估算// 已经得到 s2cnt 的数量 (剩下数量可以构建重复的 s2cnt 数量)int res s2cntPre (n1 - s1cntPre)/(s1cnt-s1cntPre) * (s2cnt - s2cntPre);// cout s1cntPre ,s2cntPre (s1cnt-s1cntPre) , (s2cnt - s2cntPre) : res endl;// 剩下数量不足s1cntPre的则继续遍历int nRest (n1 - s1cntPre) % (s1cnt-s1cntPre);for (int i 0; i nRest; i){for (char c : s1){if (c s2[i2]){i2;if (i2 ns2){res;i2 0;}}}}// 最后需要除以 n2 才是真正结果return res / n2;}else{i2cnt[i2] {s1cnt, s2cnt};}}return 0;} };
http://www.zqtcl.cn/news/607471/

相关文章:

  • 省级示范校建设网站网站制作企业有哪些公司
  • 单位做网站怎么做510企业网站系统源码
  • 福建人力资源建设网站未成年在线观看视频播放免费
  • 网站站内logo怎么做朋友圈广告30元 1000次
  • 绍兴做网站北京做公司网站
  • 青浦区网站建设公司商丘网站建设费用
  • 百度网站是怎么建设的wordpress媒体主题
  • 孝感网站建设xgsh国内比百度好的搜索引擎
  • 阅读网站怎样做网站右侧固定标题怎么做
  • 网站开发多少钱农民wordpress acf破解版
  • 厦门网站建设培训云南最便宜的网站建设
  • 吉安手机网站建设html网页布局
  • wordpress英文文章格式怎样给网站做优化
  • 新网站友链网店托管公司
  • 期末作业制作网站网站上传根目录
  • 新网站不被收录的原因兰州网络seo公司
  • 男生可以做网站编辑工作吗网站域名跟谁买
  • 我市精神文明建设的门户网站做网站需要写代码
  • 新网站推广网站搜索引擎优化的步骤
  • 网站建设20推广公司网站建设推广方案
  • 如何设计酒店网站建设好的交互网站
  • 怎么把自己的网站放到百度上九亭做网站
  • 张家界旅游网站建设网页设计作品欣赏分析
  • 订阅号自定义可以做链接网站不做网站dreamwa
  • 电子商务网站规划的原则做网站的集群方案
  • 山东建设银行怎么招聘网站自己做商城网站
  • 建设网站成本预算网站页面设计尺寸
  • 微官网和微网站首页房产网怎么查到房产
  • 高端服装产品网站建设织梦网站识别
  • 做调像什么网站找活注册网站请签署意见是写无