- 浏览: 64883 次
- 性别:
- 来自: 北京
最新评论
2012华杯小中年级初赛试题的第一题解析
原题如下
程序源码
答案是18
代码运行后输出如下
原题如下
程序源码
import java.util.HashSet; import java.util.Set; public class Sum { static private boolean isCollect(int a, int b, int c, int d, int e, int f) { int sum = a * 100 + b * 10 + c + d * 100 + e * 10 + f; if (sum > 1000) return false; int h = sum / 100; int j = (sum - h * 100) / 10; int k = sum % 10; Set s = new HashSet(); s.add(a); s.add(b); s.add(c); s.add(d); s.add(e); s.add(f); s.add(h); s.add(j); s.add(k); boolean res = s.size() == 9 && !s.contains(0); if (res) { int all = h + j + k; System.out.println(sum + ":" + all); } return res; } static int dig[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; public static void main(String[] args) { int a, b, c, d, e, f, g, h, j, k; int total = 0; int count = 0; for (int i1 = 0; i1 < dig.length; i1++) { a = dig[i1]; for (int i2 = 0; i2 < dig.length; i2++) { if (i1 == i2) { continue; } b = dig[i2]; for (int i3 = 0; i3 < dig.length; i3++) { if (i3 == i2 || i3 == i1) { continue; } c = dig[i3]; for (int i4 = 0; i4 < dig.length; i4++) { if (i4 == i1 || i4 == i2 || i4 == i3) continue; d = dig[i4]; for (int i5 = 0; i5 < dig.length; i5++) { if (i5 == i1 || i5 == i2 || i5 == i3 || i5 == i4) { continue; } e = dig[i5]; for (int i6 = 0; i6 < dig.length; i6++) { if (i6 == i1 || i6 == i2 || i6 == i3 || i6 == i4 || i6 == i5) { continue; } f = dig[i6]; total++; if (isCollect(a, b, c, d, e, f)) { count++; System.out.println("answer is:" + a + b + c + "," + d + e + f); } } } } } } } System.out.println("total check:" + total); System.out.println("answer count:" + count); } }
答案是18
代码运行后输出如下
783:18 answer is:124,659 864:18 answer is:125,739 486:18 answer is:127,359 495:18 answer is:127,368 495:18 answer is:128,367 567:18 answer is:128,439 486:18 answer is:129,357 567:18 answer is:129,438 783:18 answer is:129,654 864:18 answer is:129,735 792:18 answer is:134,658 864:18 answer is:135,729 567:18 answer is:138,429 792:18 answer is:138,654 567:18 answer is:139,428 864:18 answer is:139,725 738:18 answer is:142,596 837:18 answer is:142,695 729:18 answer is:143,586 837:18 answer is:145,692 729:18 answer is:146,583 738:18 answer is:146,592 639:18 answer is:152,487 936:18 answer is:152,784 783:18 answer is:154,629 792:18 answer is:154,638 936:18 answer is:154,782 486:18 answer is:157,329 639:18 answer is:157,482 792:18 answer is:158,634 486:18 answer is:159,327 783:18 answer is:159,624 549:18 answer is:162,387 945:18 answer is:162,783 945:18 answer is:163,782 495:18 answer is:167,328 549:18 answer is:167,382 495:18 answer is:168,327 459:18 answer is:173,286 468:18 answer is:173,295 468:18 answer is:175,293 459:18 answer is:176,283 549:18 answer is:182,367 576:18 answer is:182,394 639:18 answer is:182,457 675:18 answer is:182,493 936:18 answer is:182,754 945:18 answer is:182,763 459:18 answer is:183,276 675:18 answer is:183,492 729:18 answer is:183,546 945:18 answer is:183,762 576:18 answer is:184,392 936:18 answer is:184,752 459:18 answer is:186,273 729:18 answer is:186,543 549:18 answer is:187,362 639:18 answer is:187,452 576:18 answer is:192,384 675:18 answer is:192,483 738:18 answer is:192,546 837:18 answer is:192,645 468:18 answer is:193,275 675:18 answer is:193,482 576:18 answer is:194,382 468:18 answer is:195,273 837:18 answer is:195,642 738:18 answer is:196,542 783:18 answer is:214,569 873:18 answer is:214,659 693:18 answer is:215,478 963:18 answer is:215,748 594:18 answer is:216,378 954:18 answer is:216,738 567:18 answer is:218,349 594:18 answer is:218,376 657:18 answer is:218,439 693:18 answer is:218,475 954:18 answer is:218,736 963:18 answer is:218,745 567:18 answer is:219,348 657:18 answer is:219,438 783:18 answer is:219,564 873:18 answer is:219,654 891:18 answer is:234,657 981:18 answer is:235,746 954:18 answer is:236,718 981:18 answer is:236,745 891:18 answer is:237,654 657:18 answer is:238,419 954:18 answer is:238,716 657:18 answer is:239,418 837:18 answer is:241,596 819:18 answer is:243,576 918:18 answer is:243,675 918:18 answer is:245,673 963:18 answer is:245,718 981:18 answer is:245,736 819:18 answer is:246,573 837:18 answer is:246,591 981:18 answer is:246,735 567:18 answer is:248,319 963:18 answer is:248,715 567:18 answer is:249,318 648:18 answer is:251,397 873:18 answer is:254,619 891:18 answer is:254,637 648:18 answer is:257,391 891:18 answer is:257,634 873:18 answer is:259,614 783:18 answer is:264,519 783:18 answer is:269,514 864:18 answer is:271,593 954:18 answer is:271,683 459:18 answer is:273,186 468:18 answer is:273,195 819:18 answer is:273,546 864:18 answer is:273,591 918:18 answer is:273,645 954:18 answer is:273,681 468:18 answer is:275,193 693:18 answer is:275,418 918:18 answer is:275,643 459:18 answer is:276,183 594:18 answer is:276,318 819:18 answer is:276,543 594:18 answer is:278,316 693:18 answer is:278,415 675:18 answer is:281,394 954:18 answer is:281,673 459:18 answer is:283,176 954:18 answer is:283,671 675:18 answer is:284,391 459:18 answer is:286,173 648:18 answer is:291,357 675:18 answer is:291,384 837:18 answer is:291,546 864:18 answer is:291,573 468:18 answer is:293,175 864:18 answer is:293,571 675:18 answer is:294,381 468:18 answer is:295,173 837:18 answer is:296,541 648:18 answer is:297,351 972:18 answer is:314,658 594:18 answer is:316,278 846:18 answer is:317,529 945:18 answer is:317,628 567:18 answer is:318,249 594:18 answer is:318,276 945:18 answer is:318,627 972:18 answer is:318,654 567:18 answer is:319,248 846:18 answer is:319,527 891:18 answer is:324,567 981:18 answer is:324,657 486:18 answer is:327,159 495:18 answer is:327,168 846:18 answer is:327,519 891:18 answer is:327,564 945:18 answer is:327,618 981:18 answer is:327,654 495:18 answer is:328,167 945:18 answer is:328,617 486:18 answer is:329,157 846:18 answer is:329,517 927:18 answer is:341,586 918:18 answer is:342,576 918:18 answer is:346,572 927:18 answer is:346,581 567:18 answer is:348,219 567:18 answer is:349,218 648:18 answer is:351,297 819:18 answer is:352,467 972:18 answer is:354,618 981:18 answer is:354,627 486:18 answer is:357,129 648:18 answer is:357,291 819:18 answer is:357,462 981:18 answer is:357,624 972:18 answer is:358,614 486:18 answer is:359,127 549:18 answer is:362,187 819:18 answer is:362,457 891:18 answer is:364,527 495:18 answer is:367,128 549:18 answer is:367,182 819:18 answer is:367,452 891:18 answer is:367,524 495:18 answer is:368,127 918:18 answer is:372,546 594:18 answer is:376,218 918:18 answer is:376,542 594:18 answer is:378,216 675:18 answer is:381,294 927:18 answer is:381,546 549:18 answer is:382,167 576:18 answer is:382,194 576:18 answer is:384,192 675:18 answer is:384,291 927:18 answer is:386,541 549:18 answer is:387,162 648:18 answer is:391,257 675:18 answer is:391,284 576:18 answer is:392,184 576:18 answer is:394,182 675:18 answer is:394,281 648:18 answer is:397,251 693:18 answer is:415,278 657:18 answer is:418,239 693:18 answer is:418,275 657:18 answer is:419,238 567:18 answer is:428,139 567:18 answer is:429,138 567:18 answer is:438,129 657:18 answer is:438,219 567:18 answer is:439,128 657:18 answer is:439,218 639:18 answer is:452,187 819:18 answer is:452,367 639:18 answer is:457,182 819:18 answer is:457,362 819:18 answer is:462,357 819:18 answer is:467,352 693:18 answer is:475,218 693:18 answer is:478,215 639:18 answer is:482,157 675:18 answer is:482,193 675:18 answer is:483,192 639:18 answer is:487,152 675:18 answer is:492,183 675:18 answer is:493,182 783:18 answer is:514,269 846:18 answer is:517,329 783:18 answer is:519,264 846:18 answer is:519,327 891:18 answer is:524,367 846:18 answer is:527,319 891:18 answer is:527,364 846:18 answer is:529,317 837:18 answer is:541,296 927:18 answer is:541,386 738:18 answer is:542,196 918:18 answer is:542,376 729:18 answer is:543,186 819:18 answer is:543,276 729:18 answer is:546,183 738:18 answer is:546,192 819:18 answer is:546,273 837:18 answer is:546,291 918:18 answer is:546,372 927:18 answer is:546,381 783:18 answer is:564,219 891:18 answer is:564,327 891:18 answer is:567,324 783:18 answer is:569,214 864:18 answer is:571,293 918:18 answer is:572,346 819:18 answer is:573,246 864:18 answer is:573,291 819:18 answer is:576,243 918:18 answer is:576,342 927:18 answer is:581,346 729:18 answer is:583,146 729:18 answer is:586,143 927:18 answer is:586,341 837:18 answer is:591,246 864:18 answer is:591,273 738:18 answer is:592,146 864:18 answer is:593,271 738:18 answer is:596,142 837:18 answer is:596,241 873:18 answer is:614,259 972:18 answer is:614,358 945:18 answer is:617,328 945:18 answer is:618,327 972:18 answer is:618,354 873:18 answer is:619,254 783:18 answer is:624,159 981:18 answer is:624,357 945:18 answer is:627,318 981:18 answer is:627,354 945:18 answer is:628,317 783:18 answer is:629,154 792:18 answer is:634,158 891:18 answer is:634,257 891:18 answer is:637,254 792:18 answer is:638,154 837:18 answer is:642,195 918:18 answer is:643,275 837:18 answer is:645,192 918:18 answer is:645,273 783:18 answer is:654,129 792:18 answer is:654,138 873:18 answer is:654,219 891:18 answer is:654,237 972:18 answer is:654,318 981:18 answer is:654,327 891:18 answer is:657,234 981:18 answer is:657,324 792:18 answer is:658,134 972:18 answer is:658,314 783:18 answer is:659,124 873:18 answer is:659,214 954:18 answer is:671,283 918:18 answer is:673,245 954:18 answer is:673,281 918:18 answer is:675,243 954:18 answer is:681,273 954:18 answer is:683,271 837:18 answer is:692,145 837:18 answer is:695,142 963:18 answer is:715,248 954:18 answer is:716,238 954:18 answer is:718,236 963:18 answer is:718,245 864:18 answer is:725,139 864:18 answer is:729,135 864:18 answer is:735,129 981:18 answer is:735,246 954:18 answer is:736,218 981:18 answer is:736,245 954:18 answer is:738,216 864:18 answer is:739,125 963:18 answer is:745,218 981:18 answer is:745,236 981:18 answer is:746,235 963:18 answer is:748,215 936:18 answer is:752,184 936:18 answer is:754,182 945:18 answer is:762,183 945:18 answer is:763,182 936:18 answer is:782,154 945:18 answer is:782,163 945:18 answer is:783,162 936:18 answer is:784,152 total check:60480 answer count:336
相关推荐
iOS版微信抢红包Tweak.zip小程序
该资源内项目源码是个人的课程设计、毕业设计,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! ## 项目备注 1、该资源内项目代码都经过严格测试运行成功才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。
基于springboot社区停车信息管理系统.zip
基于springboot南皮站化验室管理系统源码数据库文档.zip
## 数据指标说明 全要素生产率(TFP)也可以称之为系统生产率。指生产单位(主要为企业)作为系统中的各个要素的综合生产率,以区别于要素生产率(如技术生产率)。测算公式为:全要素生产率=产出总量/全部资源投入量。 数据测算:包含OL、FE、LP、OP、GMM共五种TFP测算方法!数据结果包括excel和dta格式,其中重要指标包括证券代码,固定资产净额,营业总收入,营业收入,营业成本,销售费用,管理费用,财务费用,购建固定资产无形资产和其他长期资产支付的现金,支付给职工以及为职工支付的现金,员工人数,折旧摊销,行业代码,上市日期,AB股交叉码,退市日期,年末是否ST或PT等变量指标分析。文件包括计算方法说明及原始数据和代码。 数据名称:上市公司全要素生产率TFP数据及测算方法(OL、FE、LP、OP、GMM) 数据年份:2000-2023年 数据指标:证券代码、year、TFP_OLS、TFP_FE、TFP_LP1、TFP_OP、TFP_OPacf、TFP_GMM
内容概要:本文详细总结了多种编程语言下常用的算法实现资源,涵盖Python、C++、Java等流行编程语言及其相关的开源平台、在线课程和权威书籍。对于每种语言而言,均提供了具体资源列表,包括开源项目、标准库支持、在线课程及专业书籍推荐。 适合人群:适用于所有希望深入研究并提高特定编程语言算法能力的学习者,无论是编程新手还是有一定经验的技术人员。 使用场景及目标:帮助开发者快速定位到合适的算法学习资料,无论是出于个人兴趣自学、面试准备或是实际工作中遇到的具体算法问题,都能找到合适的解决方案。 其他说明:文中提及多个在线学习平台和社区网站,不仅限于某一特定语言,对于跨学科或多元化技能培养也具有很高的参考价值。
基于springboot的交通旅游订票系统源码数据库文档.zip
内容概要:本文档是一份详细的GO语言教程,涵盖了Go语言的基础语法、数据类型、控制结构、函数、结构体、接口以及并发编程等多个方面。主要内容包括Go语言的基本概念和历史背景、环境配置、基本语法(如变量、数据类型、控制结构)、函数定义与调用、高级特性(如闭包、可变参数)、自定义数据类型(如结构体、接口)以及并发编程(如goroutine、channel、select)等内容。每部分内容都附有具体的代码示例,帮助读者理解和掌握相关知识点。 适合人群:具备一定编程基础的开发者,尤其是希望深入学习和应用Go语言的技术人员。 使用场景及目标:①初学者通过本教程快速入门Go语言;②有一定经验的开发者系统复习和完善Go语言知识;③实际项目开发中利用Go语言解决高性能、高并发的编程问题。 阅读建议:本文档全面介绍了Go语言的各项基础知识和技术细节,建议按章节顺序逐步学习,通过动手实践代码示例加深理解。对于复杂的概念和技术点,可以通过查阅更多资料或进行深入研究来巩固知识。
GEE训练教程
memcached笔记资料,配套视频:https://www.bilibili.com/list/474327672?sid=4486766&spm_id_from=333.999.0.0&desc=1
基于springboot校内跑腿业务系统源码数据库文档.zip
计算机控制光感自动窗帘控制系统设计.doc
基于SpringBoot的校园服务系统源码数据库文档.zip
基于SpringBoot+Vue的美容店信息管理系统源码数据库文档.zip
基于springboot程序设计基础课程辅助教学系统源码数据库文档.zip
这是一个原生的JS网页版斗地主小游戏,代码注释全。带有斗地主游戏基本的地主、选牌、提示、出牌、倒计时等功能。简单好玩,欢迎下载
基于springboot亚运会志愿者管理系统源码数据库文档.zip
该资源内项目源码是个人的课程设计、毕业设计,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! ## 项目备注 1、该资源内项目代码都经过严格测试运行成功才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。
GEE训练教程——Landsat5、8和Sentinel-2、DEM和各2哦想指数下载
基于springboot家校合作平台源码数据库文档.zip