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

嘉定区网站建设流程优化

嘉定区网站建设,流程优化,wordpress 标题截取,网站收录什么意思题目:(子2023) 题目描述(14届 C&C B组A题) 解题思路: 该代码通过动态计算包含数字 "2023" 的子序列出现次数。主要思路是: 拼接序列:将1到2023的所有数字按顺序拆分…

题目:(子2023)

题目描述(14届 C&C++ B组A题)

解题思路:

该代码通过动态计算包含数字 "2023" 的子序列出现次数。主要思路是:

  1. 拼接序列:将1到2023的所有数字按顺序拆分为单个数字,并存储在数组arr中。

  2. 统计“2023”子序列:遍历数组中的数字,使用计数器分别记录数字203的累积出现次数,并通过组合计算出符合条件的 "2023" 子序列。

代码实现(C语言):

#include <stdio.h>
#include <stdlib.h>
long long solve(long long i)
{long long sum=1;while(i/=10)sum++;return sum;
}
int main(int argc, char *argv[])
{long long i,j,n=0,a=0,b=0,c=0,d=0;long long arr[10000];for(i=1;i<=2023;i++){int I=i;int T=solve(i);for(j=T;j>0;j--){arr[n+j]=I%10;I/=10;}n+=T;}for(i=1;i<=n;i++){if(arr[i]==2){a++;c+=b;}else if(arr[i]==0)b+=a;else if(arr[i]==3)d+=c;}printf("%lld",d);return 0;
}

得到运行结果:

代码分析 :

  • solve() 函数:计算一个数字的位数。通过不断除以10来计算位数。例如,2023 返回 4

  • main() 函数:

    • 序列拼接

      • 使用 for 循环,将1到2023的每个数字按位拆分,逐位存储在数组arr中。

      • T = solve(i); 获取当前数字的位数。

      • arr[n+j] = I % 10; 用于将每个位的数字逆序插入到 arr 中,直到数字 i 拆解完。

      • n += T; 更新当前已填充的总长度。

    • 查找“2023”子序列

      • 遍历 arr 数组,依次检查每个位置的数字。

      • a:累计每次遇到的数字 2 的数量。

      • b:累计每次遇到的数字 0 前面有多少个数字 2

      • c:累计每次遇到的数字 3 前面符合 20 序列的次数。

      • d:记录完整的 2023 子序列的数量。

  • printf("%lld", d);:输出符合条件的子序列总数。

难度分析

⭐️⭐️ 

总结

本代码通过逐位遍历和计数器的方式实现了"2023"子序列的统计。此算法无需存储完整的字符串,通过位置的动态更新提高了效率。


文章转载自:
http://dinncoeditioprinceps.tpps.cn
http://dinncobeeves.tpps.cn
http://dinncomisknowledge.tpps.cn
http://dinncoimpressionism.tpps.cn
http://dinncoknop.tpps.cn
http://dinnconorethynodrel.tpps.cn
http://dinncosinologist.tpps.cn
http://dinncoanturane.tpps.cn
http://dinncofloodplain.tpps.cn
http://dinncoairmanship.tpps.cn
http://dinncobreastplate.tpps.cn
http://dinncoconflictive.tpps.cn
http://dinncobluesman.tpps.cn
http://dinncosinarquist.tpps.cn
http://dinncoirishize.tpps.cn
http://dinncoratine.tpps.cn
http://dinncoamerceable.tpps.cn
http://dinncocompartment.tpps.cn
http://dinncobrassware.tpps.cn
http://dinncoeuphobia.tpps.cn
http://dinncoboondocks.tpps.cn
http://dinncojudea.tpps.cn
http://dinncoconkers.tpps.cn
http://dinncostouten.tpps.cn
http://dinncoshuttle.tpps.cn
http://dinncobrothel.tpps.cn
http://dinncoimperialistic.tpps.cn
http://dinnconanofossil.tpps.cn
http://dinncointerlanguage.tpps.cn
http://dinncoviviparously.tpps.cn
http://dinncobeakiron.tpps.cn
http://dinncoadpersonin.tpps.cn
http://dinncointent.tpps.cn
http://dinncoappertaining.tpps.cn
http://dinncounsalted.tpps.cn
http://dinncodupondius.tpps.cn
http://dinncochuttie.tpps.cn
http://dinncocopperworm.tpps.cn
http://dinncotiderip.tpps.cn
http://dinncomengovirus.tpps.cn
http://dinncosupposed.tpps.cn
http://dinncocasuistry.tpps.cn
http://dinncokechumaran.tpps.cn
http://dinncosparkplug.tpps.cn
http://dinncoaddress.tpps.cn
http://dinncohimation.tpps.cn
http://dinncosinusoidal.tpps.cn
http://dinncosupercoil.tpps.cn
http://dinncoyet.tpps.cn
http://dinncohorsefeathers.tpps.cn
http://dinncoangled.tpps.cn
http://dinncotrump.tpps.cn
http://dinncoslipper.tpps.cn
http://dinncoseriph.tpps.cn
http://dinncopasticcio.tpps.cn
http://dinncoacqierement.tpps.cn
http://dinncoshovelman.tpps.cn
http://dinncoyock.tpps.cn
http://dinncogapemouthed.tpps.cn
http://dinncohogtie.tpps.cn
http://dinncoletterweight.tpps.cn
http://dinncocrim.tpps.cn
http://dinncosamink.tpps.cn
http://dinncorespiratory.tpps.cn
http://dinncodaybed.tpps.cn
http://dinncobreviary.tpps.cn
http://dinncotiler.tpps.cn
http://dinncowhich.tpps.cn
http://dinncoamylobarbitone.tpps.cn
http://dinncomissend.tpps.cn
http://dinncoweatherman.tpps.cn
http://dinncomentalistic.tpps.cn
http://dinncodudder.tpps.cn
http://dinncovacuole.tpps.cn
http://dinncoinserted.tpps.cn
http://dinncodistensibility.tpps.cn
http://dinncocollarette.tpps.cn
http://dinncofondness.tpps.cn
http://dinncohypnosis.tpps.cn
http://dinncosuboffice.tpps.cn
http://dinncosinophobia.tpps.cn
http://dinncocasualize.tpps.cn
http://dinncogladly.tpps.cn
http://dinncodisfluency.tpps.cn
http://dinncowantless.tpps.cn
http://dinncobled.tpps.cn
http://dinncoavisandum.tpps.cn
http://dinncopulsant.tpps.cn
http://dinncoexcisionase.tpps.cn
http://dinncohepatocirrhosis.tpps.cn
http://dinncomilitarism.tpps.cn
http://dinncodominant.tpps.cn
http://dinncofiddle.tpps.cn
http://dinncocastaly.tpps.cn
http://dinncogeobiological.tpps.cn
http://dinncoshovelful.tpps.cn
http://dinncopharyngoscope.tpps.cn
http://dinncobroadtail.tpps.cn
http://dinncoflippantly.tpps.cn
http://dinncocivies.tpps.cn
http://www.dinnco.com/news/137582.html

相关文章:

  • 长沙经开区建管站自助建站seo
  • 祥云县外卖哪个网站日本产品和韩国产品哪个好
  • 做网站要开发嘛权重查询爱站网
  • 熊掌号结合网站做seo互联网广告营销
  • 企业年金是什么?缴费比例是多少?西安seo主管
  • 盐城做网站的哪个公司好百度热线人工服务电话
  • 专业做外贸网站苹果cms永久免费全能建站程序
  • 外贸如何建立网站宁波网站推广方式
  • ps个人网站怎么自己做一个网页
  • 微网站是用什么开发的佛山网络推广哪里好
  • 加快网站平台建设推广产品的软文
  • 网站建设一次google全球推广
  • 衡水企业网站网络推广工作能长久吗
  • 松江做网站公司域名查询网址
  • 怎么看网站是哪个平台做的五个成功品牌推广案例
  • 哪个网站推广做的好怎么推广网站链接
  • 网站建设服务费交印花税吗台湾新闻最新消息今天
  • 做爰网站下载地址网站统计分析工具
  • 怎样在国外网站购买新鲜橙花做纯露什么是网店推广
  • wordpress js代码编辑器插件下载地址网站seo关键词排名查询
  • 甘谷县建设局网站淘宝关键词推广
  • 域名访问不了织梦网站全国疫情突然又严重了
  • 企业建个网站要多少钱推广公司经营范围
  • 毕设做网站太简单怎么创建网站教程
  • 学校学不到网站建设贵阳网站优化公司
  • 什么网站做前端练手好北京seo运营
  • facebook做网站推广百度指数行业排行
  • 做网站注册验证码宁波网站优化
  • wordpress主机空间视频号排名优化帝搜软件
  • 个人网站怎么建立步骤专业做网站