请填写表示他出生年份的四位数字,不要填写任何多余内容。
代码:
[java] view plain copy public class T1 { public static void main(String[] args) { for (int i = 1; i < 100; i++) { if(i*i/100==18){ System.out.println(i*i-i); } } } }
[java] view plain copy import java.util.Arrays; public class T2 { public static void main(String[] args) { String s=""; for (int i = 10; i < 1000; i++) { for (int a = 0; a < 10; a++) { for (int b = 0; b < 10; b++) { for (int c = 0; c < 10; c++) { //if(i*a>=1000||i*a<100||i*b>=1000||i*b<100||i*b>=1000||i*b<100) continue; int num=i*(a*100+b*10+c); if(num>=10000&&num<100000){ s=""+i+a+b+c+i*a+i*b+i*c+num; if(s.length()==20&&check(s)){ System.out.println(num); //System.out.println(s); } } } } } } } private static boolean check(String s) { char[] ch=s.toCharArray(); Arrays.sort(ch); if("00112233445566778899".equals(new String(ch))) return true; else return false; } }
代码:
[java] view plain copy public class T3 { public static void main(String[] args) { //abcdefghijklmnopq String s="bckfqlajhemgiodnp";//bckfqlajhemgiodnp System.out.println(s); int[] arr = quanzhi(s); long sum=0; for (int i = arr.length-1,k=0; i >=0; i--,k++) { sum+=arr[i]*jiecheng(k); } System.out.println(sum); } private static int[] quanzhi(String s) { int[] arr=new int[s.length()]; for (int i = 0; i < arr.length; i++) { int q=0; for (int j = i+1; j < arr.length; j++) { if(s.charAt(i)-s.charAt(j)>0){ q++; } } arr[i]=q; } return arr; } private static long jiecheng(long l) { if(l==0||l==1){ return 1; } long j=1; for (int i = 1; i <=l; i++) { j=j*i; } return j; } }
[java] view plain copy import java.util.Scanner; import java.math.BigDecimal; public class T5 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); double lv=sc.nextDouble()/100; double m=sc.nextDouble(); double ed=0,sy=100; double x=10000/m;//怎么确定一个大概的范围?? for (double k = x; k < x+50; k+=0.01) { double d=10000; BigDecimal kk=BigDecimal.valueOf(k); k=kk.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue(); for (int i = 1; i <= m; i++) { BigDecimal bd=BigDecimal.valueOf(d+d*(lv/12)-k); d=bd.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue(); } if(Math.abs(sy-d)<sy){ ed=k; sy=d; //System.out.println(k+": "+d); } } System.out.println((int)(ed*100)); } }
代码:
[java] view plain copy import java.util.Scanner; public class T6 { static int[][] filter=new int[10][10]; //不可能出现的情况 static boolean[][] know=new boolean[10][10];//标记已知线段 static int[] stamp=new int[9]; //存放搜索出来的点 static boolean[] vis=new boolean[10]; //已经用过的点 static int n,result; //n:已知线段数目,result可能出现的情况 public static void main(String[] args) { Scanner sc=new Scanner(System.in); //接收已知线段 //n=sc.nextInt(); // for (int i = 0; i < n; i++) { // int a=sc.nextInt(); // int b=sc.nextInt(); // know[a][b]=know[b][a]=true; // } //不可能的情况 filter[1][3]=filter[3][1]=2; filter[4][6]=filter[6][4]=5; filter[7][9]=filter[9][7]=8; filter[1][7]=filter[7][1]=4; filter[2][8]=filter[8][2]=5; filter[3][9]=filter[9][3]=6; filter[1][9]=filter[9][1]=5; filter[3][7]=filter[7][3]=5; vis[0]=true; dfs(0); System.out.println(result); } private static void dfs(int count) { if(count>=4) { int nKnow=0; for(int i=1;i<count;i++) { if(know[stamp[i]][stamp[i-1]]) // nKnow++; } result++;//测试总共有多少种情况 if(n==nKnow){ //result++;//有已知线段的情况 for (int i = 0; i < count; i++) { System.out.print(stamp[i]); } System.out.println(); } } for(int i=1;i<=9;i++) { if(count>0&&!vis[filter[stamp[count-1]][i]]) continue; if(!vis[i]) { vis[i]=true; stamp[count]=i; dfs(count+1); vis[i]=false; } } return ; } }
代码:
[java] view plain copy import java.util.Scanner; public class T7 { static boolean[][] data; static boolean[] vis; static boolean fal=false; public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int m=sc.nextInt(); data=new boolean[n+1][n+1]; int[] arr=new int[n+1]; vis=new boolean[n+1]; for (int i = 1; i < arr.length; i++) { arr[i]=i; } //标记走得通得路线 for (int i = 0; i < m; i++) { int a=sc.nextInt(); int b=sc.nextInt(); data[a][b]=data[b][a]=true; } int begin=sc.nextInt(); int end=sc.nextInt(); sc.close(); //先看从begin到end走得通吗 vis[0]=true; dfs(begin,end,0); if(!fal){ System.out.println("-1"); return; } //System.out.println("OK"); //走得通,遍历去除每一个点 int count=0; for (int i = 1; i < arr.length; i++) { if(arr[i]!=begin&&arr[i]!=end) fal=false; dfs(begin,end,arr[i]); if(fal==false) count++; } System.out.println(count); } private static void dfs(int begin, int end, int i) { //System.out.println(begin+" "+end+" "+data[begin][end]); if(data[begin][end]==true){ fal=true; return; } for (int j = 1; j < data.length; j++) { if(j!=i&&!vis[begin]&&data[begin][j]==true){ vis[begin]=true; dfs(j,end,i); vis[begin]=false; } } return; } }