1 | 2 | 3 | 4 | 5 | |||||
哪天返回 | 猴子分香蕉 | 字母阵列 | 第几个幸运数 | 书号验证 | |||||
6 | 7 | 8 | 9 | 10 | |||||
打印大X | 缩位求和 | 等腰三角形 | 小朋友崇拜圈 | 耐摔指数 |
1.哪天返回
11
package 哪天返回;
public class Main {
public static void main(String[] args) {
int money = 1;
int sum = 0;
for (int i = 1; ; i++,money+=2) {
sum+=money;
System.err.println("第"+i+"天 :"+sum);
if (sum >= 108) {
break;
}
}
}
}
2.猴子分香蕉
package 猴子分香蕉;
public class Main {
public static void main(String[] args) {
for (int i = 17; i < 1000000; i++) {
int num = i;
if (num % 5 == 1) {
num=num-1;
num -= (num/5);
if (num%5==2) {
num -= 2;
num -= (num/5);
if (num%5==3) {
num-=3;
num -=(num/5);
if (num%5==4) {
num-=4;
num-=(num/5);
if (num%5==0) {
System.out.println(i);
return;
}
}
}
}
}
}
}
}
3.字母阵列
FOAIQNALWIKEGNICJWAOSXDHTHZPOLGYELORAUHOHCZIERPTOOJUITQJCFNIYYQHSBEABBQZPNGYQTCLSKZFCYWDGOAIADKLSNGJ
GSOZTQKCCSDWGUWAUOZKNILGVNLMCLXQVBJENIHIVLRPVVXXFTHQUXUAVZZOFFJHYLMGTLANQIAOQQILCDCJERJASNCTLYGRMHGF
TSDFYTLVIBHKLJVVJUDMKGJZGNNSTPVLCKTOFMUEUFSVQIAUVHNVFTGBDDARPKYNNCUOYUAZXQJNOEEYKLFRMOEMHUKJTPETHLES
FKVINSLWEVGAGMKVFVIUBMYOIAFHLVNKNTYKTZWVXQWRWIGPENFXYDTKRVPKRTHMGHVYOCLDCKMEKRLGEKBYUCLOLYPAKPFSOREH
KWPUOLOVMOFBIXYACWRDYBINTMPASPCEOKHXQIGBQQMCEOIVULIEOPFSCSIHENAJCVDPJDOIWIIULFDNOZOFVAMCABVGKAKCOZMG
XWMYRTAFGFOCNHLBGNGOXPJSTWLZUNNAGIRETGXFWAQSSJPFTQAXMTQWMZWYVEPQERKSW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SQPCELDIWDHOQWAUHILGLPYRIICTLFSOYKQZYZOCIZPTECSWOODGGBDTSGIMYGMVPJPRPEVWOOKYFWRGXHWUCRQNYJEMSYL
XWOFXFVDXPTHYTCEGMODCILAHYBREZVVHOUPZKCNHUEVPMKHUBNRPFMWXVQACVZCALZLYMZSBLCEASPMIEFOTGKMPGWYQADSNDPR
QPHAVLZDZLKIEISFLLVWXAVBZLZIJRHGROUVGXRDLUJAXNHBBZYNCVERJGSKLWZEKGJBCWMSMLYIHZFFMIOGVIMZQBSRHQWAADYN
MNXEGTDXCDKIUDOISQXEUJWETPELKBCYFSDNJQWNNBPYMWBUPQBAAINMYZOYCEGNLFNNHZFEMSQVXJJGWBCRAVKZFWFBKMBRVBFD
HKACSZIUWUXLWKFPKOCUQJEPQDZCMUJFLVCLIOQQRVKSWFIAKNHMRLNJTKGVNTGLCVPVMBLJANOBCXUGVWBJYSIXZQVAVFWILWFB
QWNLTPMCYHRSKVHXLONRANWKWXUTHYQLIOFKGDBMSWDRCYRKVSAGGRJMWQYQFLMUIGGCLAUQAACTYLPZEOJBHMWRKHCRXGTGRMUP
CPQKJRBLYDNPUGHCRBVYBAIRVCAWLBWVWCMKNBIRKJOUGYQEBQRHDSTWXDIWGRVMLIJFBWHLHCDAAVUDLZSCGQNOUXVUIVIZZZMD
NMHGYPFUUDWKQGTAKKGCDFJFYJFNRZVXDPGZEAMWQVQZODKTXHIYFVKJSSAWVHYCUCZMLLBPXTILDYJQEMWDRUFKISOUVPUDTYPB
FDAQUBXHUJYTAYNWVIJNUSQDTQDEMUAPWXRYUWONTBDZCHZOUEGPMWEZTQWWSHAYOBWVTDIMZYNVNZKUHOFCQKPHJXWNRCGUJEKO
WSDAUGUTVWCVHEMOIRJJGTANUWTSAIXXEVZTBDHPGSRHHVWCDZVZYRJTLONIJVXEATHQXOUKBIGZONFRSZIOGWNTYAJYLQCGEOWY
41
package 字母阵列;
import java.util.Scanner;
public class Main {
static int count = 0;
public static void main(String[] args) {
Scanner sr = new Scanner(System.in);
//创建地图
char[][] map = new char[100][100];
for (int i = 0; i < map.length; i++) {
String s = sr.next();
map[i] = s.toCharArray();
}
//寻找L起点
for (int i = 0; i < map.length; i++) {
for (int j = 0; j < map[0].length; j++) {
dfs(i, j, map);//以此位置为起点
}
}
System.out.println(count);
}
private static void dfs(int i, int j, char[][] map) {
//LANQIAO
String Model = "LANQIAO";
//方向移动数组
int[] dx = {1,-1,0,0,-1,-1,1,1};
int[] dy = {0,0,-1,1,-1,1,-1,1};
for (int k = 0; k < 8; k++) {
int nx = i;//起点位置
int ny = j;
int step = 0;//字符匹配计数器
//按此方向循环蓝桥长度
for (int p = 0; p < Model.length(); p++) {
nx += dx[k];
ny += dy[k];
if (nx >= 0 && ny >= 0 && nx < map.length && ny < map[0].length && map[nx][ny] == Model.charAt(p)) {
step++;
continue;
}else {
break;
}
}//此方向完美匹配长度,count++;
if (step == Model.length()) count++;
}
return;
}
}
4.第几个幸运数
1905
package 第几个幸运数;
public class Main {
public static void main(String[] args) {
// 统计最后的幸运数
int count = 0;
// 数字太大所以用Long型,数字最后+L表示形式!!因为JAVA默认int类型~
Long num = 59084709587505L;
for (int i = 0; Math.pow(3, i) < num; i++) { // 3的i次方<num
for (int j = 0; Math.pow(5, j) < num; j++) { // 5的j次方<num
for (int k = 0; Math.pow(7, k) < num; k++) { // 7的k次方<num
if (Math.pow(3, i) * Math.pow(5, j) * Math.pow(7, k) <= num) { // 如果三个次方同时相乘<num,继续循环!!
count++; // 求得幸运数结果
}
}
}
}
// 千万注意,因为i,j,k的for初始值为0,0没有意义,所以在原结果-1,求得答案1905!!
System.out.println(count - 1);
}
}
5.书号验证
package 书号验证;
public class Main
{
static boolean f(String s){
int k=1;
int sum = 0;
for(int i=0; i<s.length(); i++){
char c = s.charAt(i);
if(c=='-' || c==' ') continue;
sum += (c-'0')*(k%2==0?3:1); //填空
k++;
if(k>12) break;
}
return s.charAt(s.length()-1)-'0' == (10-sum % 10)%10;
}
public static void main(String[] args){
System.out.println(f("978-7-301-04815-3"));
System.out.println(f("978-7-115-38821-6"));
}
}
6.打印大X
package 打印大X;
public class Main
{
static void f(int h, int w){
System.out.println(String.format("高度=%d, 笔宽=%d",h,w));
int a1 = 0;
int a2 = h - 1;
for(int k=0; k<h; k++){
int p = Math.min(a1,a2);
int q = Math.max(a1+w,a2+w);
for(int i=0; i<p; i++) System.out.print(" ");
if(q-p<w*2){
for(int i = p ; i < q ;i++)System.out.print("*"); ; //填空
}
else{
for(int i=0; i<w; i++) System.out.print("*");
for(int i=0; i<q-p-w*2; i++) System.out.print(" ");
for(int i=0; i<w; i++) System.out.print("*");
}
System.out.println();
a1++;
a2--;
}
}
public static void main(String[] args){
f(15,3);
f(8,5);
}
}
7.缩位求和
package 缩位求和;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sr = new Scanner(System.in);
String s = sr.next();
while (s.length() > 1) {
int num = 0;
for (int i = 0; i < s.length(); i++) {
num += s.charAt(i)-'0';
}
s = num+"";
}
System.out.println(s);
}
}
8.等腰三角形
例如:
输入:
5
程序应该输出:
....1
...2.1
..3...2
.4.....1
567891011
再例如:
输入:
10
程序应该输出:
.........1
........2.2
.......3...2
......4.....2
.....5.......1
....6.........2
...7...........0
..8.............2
.9...............9
1011121314151617181
再例如:
输入:
15
程序应该输出:
..............1
.............2.3
............3...2
...........4.....3
..........5.......1
.........6.........3
........7...........0
.......8.............3
......9...............9
.....1.................2
....0...................8
...1.....................2
..1.......................7
.1.........................2
21314151617181920212223242526
资源约定:
峰值内存消耗(含虚拟机) < 256M
CPU消耗 < 1000ms
package 数字三角形;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sr = new Scanner(System.in);
int n =sr.nextInt();
String str = "";
for (int i = 1; i <= n*2+3; i++) {
str += i;
}
//计算整个字串长度
int len = ( n-1 ) + ( n*2-1 ) + ( n-2 );
str = str.substring(0,len);
String left = str.substring(0,(n-1));
String down = str.substring((n-1) ,(n-1) + (n*2-1));
String right = str.substring((n-1) + (n*2-1) , len);
right = new StringBuilder(right).reverse().toString();
// System.out.println(left);
// System.out.println(down);
// System.out.println(right);
//行
for (int j = n-1; j >= 1; j--)
System.out.print(".");
System.out.println(left.charAt(0));
for (int i = 2; i < n; i++) {
//输出前置*
for (int j = n-i; j >= 1; j--)
System.out.print(".");
//左
System.out.print(left.charAt(i-1));
//输出中间*
for (int j = 1; j <= i-2; j++)
System.out.print("..");
System.out.print(".");
//右
System.out.println(right.charAt(i-2));
}
System.out.println(down);
}
}
9.小朋友崇拜圈
package 小朋友崇拜圈;
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sr = new Scanner(System.in);
int n = sr.nextInt();
int max = 0;//最大值圈
int[] child = new int[n+1];//存储小朋友崇拜的人,序号1开始,所以+1
for (int i = 1; i < child.length; i++) {
child[i] = sr.nextInt();
}
//遍历起点
for (int i = 1; i < child.length; i++) {
//从这个起点开始寻找崇拜圈
ArrayList<Integer> list = new ArrayList<Integer>();
list.add(i);
while (!list.isEmpty()) {
//看看刚加进来的小朋友崇拜谁
int id = child[list.get(list.size()-1)];
//这个人之前被崇拜你的人崇拜过,形成圈
if (list.contains(id)) {
System.out.print(list+" ");
System.out.println(list.size() - list.indexOf(id));
max = Math.max(max, list.size() - list.indexOf(id));
break;
}//寻找新加进来的整个人崇拜的人
list.add(id);
}
}
System.out.println(max );
}
}
10.耐摔指数
package 耐摔次数;
public class Main {
public static void main(String[] args) {
int[][] dp = new int[1000+1][3+1];
//手机数量为1时的测试次数了
for (int i = 1; i < dp.length; i++) {
dp[i][1] = i;
}
for (int i = 1; i < dp.length; i++) {
//由于上面已经设置了手机数量为1时的测试次数了
//所以只需从手机数量为2开始进行遍历即可
for (int j = 2; j < dp[0].length; j++) {
//取一个不影响结果的数
int min = Integer.MAX_VALUE;
//从第1层到第 i 层,逐一尝试所有决策,取最优的
//每一层最坏情况下(max 测试次数最多)的最好结果(min)
for (int k = 1; k <= i; k++) {
min = Math.min(min,
Math.max(dp[k-1][j-1], dp[i-k][j]));
}
//需要加上本次测试的次数,因此需要+1
dp[i][j]=min+1;
}
}
System.out.println(dp[1000][3]);
}
}