第七届蓝桥杯Java B组省赛的答案.docxVIP

  • 3
  • 0
  • 约7.82千字
  • 约 28页
  • 2018-07-12 发布于福建
  • 举报
第七届蓝桥杯Java B组省赛的答案

package com.diqijie.shengsai;/** * @author leibaobao * 煤球数目 * 解:100层为1+2+3....+100 = 5050 */public class _1 { public static void main(String[] args) { // TODO Auto-generated method stub int sum = 0; for(int i = 1; i = 100; i++){ for(int j = 1; j = i; j++) sum += j; } System.out.println(sum); }}package com.diqijie.shengsai;/** * @author leibaobao * 生日蜡烛 * 解:人最大也不过100岁,不要想太多。暴力一点 */public class _2 { public static void main(String[] args) { // TODO Auto-generated method stub int sum = 0; for(int i = 0; i 100; i++){ for(int j = i; j 100; j++){ sum += j; if(sum == 236) System.out.println(i); } sum = 0; } }} package com.diqijie.shengsai;import java.util.HashSet;/** * @author leibaobao * 凑算式 * 解:前几题不要多想,暴力一点。但是Java能不用大数不要去用大数 * 麻烦,慢。这题通分加for循环不就OK了吗 */public class _3 { public static void main(String[] args) { // TODO Auto-generated method stub int count = 0; for(int a = 1; a 10; a++) for(int b = 1; b 10; b++) for(int c = 1; c 10; c++) for(int d = 1; d 10; d++) for(int e = 1; e 10; e++) for(int f = 1; f 10; f++) for(int g = 1; g 10; g++) for(int h = 1; h 10; h++) for(int i = 1; i 10; i++) { if(a!=ba!=ca!=da!=ea!=fa!=ga!=ha!=i b!=cb!=db!=eb!=fb!=gb!=hb!=i c!=dc!=ec!=fc!=gc!=hc!=i d!=ed!=fd!=gd!=hd!=i e!=fe!=ge!=he!=i f!=gf!=hf!=i g!=hg!=ii!=h){ int temp_1 = b*(g*100 +h*10 +i); int temp_2 = c*(d*100+e*10+f); int temp_3 = c*(g*100 +h*10 +i); if((temp_1+temp_2)%temp_3 == 0) if(a + (temp_1+temp_2)/temp_3 == 10){ count++; } } } System.out.println(count); }} package com.diqijie.shengsai;/** * @author leibaobao 分小组 解:这个读懂即可 */public class _4 { public static String remain(int[] a) { String s = ; for (int i = 0; i a.length; i++) { if (a[i] == 0) s += (char) (i + A); } return s; } public static void f

文档评论(0)

1亿VIP精品文档

相关文档