1.題目標題: 高斯日記
大數學家高斯有個好習慣:不管如何都要記日記。java
他的日記有個不同凡響的地方,他從不註明年月日,而是用一個整數代替,好比:4210數組
後來人們知道,那個整數就是日期,它表示那一天是高斯出生後的第幾天。這或許也是個好習慣,它時時刻刻提醒着主人:日子又過去一天,還有多少時光能夠用於浪費呢?瀏覽器
高斯出生於:1777年4月30日。
在高斯發現的一個重要定理的日記上標註着:5343,所以可算出那天是:1791年12月15日。spa
高斯得到博士學位的那天日記上標着:8113 .net
請你算出高斯得到博士學位的年月日。blog
提交答案的格式是:yyyy-mm-dd, 例如:1980-03-21ip
請嚴格按照格式,經過瀏覽器提交答案。
注意:只提交這個日期,不要寫其它附加內容,好比:說明性的文字。get
分析:這實際就是「三天打魚、兩天曬網問題」。
數學
程序實現:(java寫的)string
- package Forth;
-
- public class DateOfNdays {
-
-
-
-
-
-
- boolean IsleapYear(int year){
- return (year % 400 == 0 || year % 4 == 0 && year % 100 != 0);
- }
-
-
-
-
- int GetMaxDay(int year,int month,int day){
- switch(month){
- case 1:
- case 3:
- case 5:
- case 7:
- case 8:
- case 10:
- case 12:
- return 31;
- case 4:
- case 6:
- case 9:
- case 11:
- return 30;
- case 2:
- return (IsleapYear(year)?29:28);
- default:
- return -1;
- }
- }
-
-
-
- void GetXDays(int year,int month,int day,int X){
- for(int i = 1; i <= X; i++){
- if(day != GetMaxDay(year,month,day)){
- day++;
- }else{
- if(month != 12){
- month++;
- day = 1;
- }else{
- month = day = 1;
- year++;
- }
- }
-
- }
- System.out.println(X+"天后的日期是"+year+"/"+month+"/"+day);
- }
-
- }
答案:1799-7-16
2.題目標題: 排它平方數
小明正看着 203879 這個數字發呆。
原來,203879 * 203879 = 41566646641
這有什麼神奇呢?仔細觀察,203879 是個6位數,而且它的每一個數位上的數字都是不一樣的,而且它平方後的全部數位上都不出現組成它自身的數字。
具備這樣特色的6位數還有一個,請你找出它!
再概括一下篩選要求:
1. 6位正整數
2. 每一個數位上的數字不一樣
3. 其平方數的每一個數位不含原數字的任何組成數位
答案是一個6位的正整數。
請經過瀏覽器提交答案。
注意:只提交另外一6位數,題中已經給出的這個不要提交。
注意:不要書寫其它的內容(好比:說明性的文字)。
- package Forth;
-
- public class ExcludeNumber {
-
-
-
- long PingNum = 0;
-
-
-
-
- public boolean IsSame(long x){
- long store[] = new long[7];
- long r;
- int i = 0;
- while(x != 0){
- r = x % 10;
- x = x / 10;
- store[i] = r;
- i++;
- }
-
- long result;
- for(int j = 0; j < 5; j++){
- result = store[j];
- for(int k = j+1; k < 6; k++){
- if(result == store[k])
- return true;
- }
- }
-
- return false;
- }
- public boolean IsSame2(long Num,long n){
- long store[] = new long[7];
- long r;
- int i = 0;
- while( n != 0){
- r = n % 10;
- n = n / 10;
- store[i] = r;
- i++;
- }
-
- long storeping[] = new long[18];
- i = 0;
- while(Num != 0){
- r = Num % 10;
- Num = Num / 10;
- storeping[i] = r;
- i++;
- }
-
- for(int k = 0; k < 6; k++){
- for(int j = 0; j < i; j++){
- if(store[k] == storeping[j])
- return true;
- }
- }
-
- return false;
- }
-
- public void selectNum(){
-
- for(long n = 100000; n <= 999999;n++){
- if(IsSame(n))
- continue;
- else{
- PingNum = n*n;
- if(IsSame2(PingNum,n))
- continue;
- else
- System.out.println(n);
- }
- }
- }
- }
答案:639172
3.標題: 振興中華
小明參加了學校的趣味運動會,其中的一個項目是:跳格子。
地上畫着一些格子,每一個格子裏寫一個字,以下所示:(也可參見p1.jpg)
從我作起振
我作起振興
作起振興中
起振興中華
比賽時,先站在左上角的寫着「從」字的格子裏,能夠橫向或縱向跳到相鄰的格子裏,但不能跳到對角的格子或其它位置。一直要跳到「華」字結束。
要求跳過的路線恰好構成「從我作起振興中華」這句話。
請你幫助小明算一算他一共有多少種可能的跳躍路線呢?
答案是一個整數,請經過瀏覽器直接提交該數字。
注意:不要提交解答過程,或其它輔助說明類的內容。
-
-
-
- int array[][] =
- {{0,1,2,3,4},
- {1,2,3,4,5},
- {2,3,4,5,6},
- {3,4,5,6,7}};
- int copyarray[][] = new int[4][5];
- int startI = 0, startJ = 0;
- int endI = 3, endJ = 4;
- int success = 0;
- int count = 0;
-
-
-
-
-
- public void initcopy(){
- for(int k = 0; k < 4; k++){
- for(int d = 0; d < 5; d++){
- copyarray[k][d] = 10;
- }
- }
- }
-
-
-
- public void visit(int i,int j){
- copyarray[i][j] = array[i][j];
- if(i == endI && j == endJ){
- count++;
- System.out.print("\n 顯示路徑:\n");
- for(int k = 0; k < 4; k++){
- for(int d = 0; d < 5; d++){
- if(copyarray[k][d] == 0)
- System.out.print("從");
- else if(copyarray[k][d] == 1)
- System.out.print("我");
- else if(copyarray[k][d] == 2)
- System.out.print("作");
- else if(copyarray[k][d] == 3)
- System.out.print("起");
- else if(copyarray[k][d] == 4)
- System.out.print("振");
- else if(copyarray[k][d] == 5)
- System.out.print("興");
- else if(copyarray[k][d] == 6)
- System.out.print("中");
- else if(copyarray[k][d] == 7)
- System.out.print("華");
- else if(copyarray[k][d] == 10)
- System.out.print("一");
- else
- System.out.print("一");
-
- }
- System.out.println();
- }
- }
- if(j != 4 && array[i][j+1] == array[i][j]+1) visit(i,j+1);
- if(i != 3 && array[i+1][j] == array[i][j]+1) visit(i+1,j);
-
- copyarray[i][j] = 10;
- }
-
-
-
- public void test(){
-
- initcopy();
- visit(startI,startJ);
- System.out.println("共有 "+count+" 種");
- }
-
- }
結果截圖:

4.標題: 顛倒的價牌
小李的店裏專賣其它店中下架的樣品電視機,可稱爲:樣品電視專賣店。
其標價都是4位數字(即千元不等)。
小李爲了標價清晰、方便,使用了預製的相似數碼管的標價籤,只要用顏色筆塗數字就能夠了(參見p1.jpg)。
這種價牌有個特色,對一些數字,倒過來看也是合理的數字。如:1 2 5 6 8 9 0 均可以。這樣一來,若是牌子掛倒了,有可能徹底變成了另外一個價格,好比:1958 倒着掛就是:8561,差了幾千元啊!!
固然,多數狀況不能倒讀,好比,1110 就不能倒過來,由於0不能做爲開始數字。
有一天,悲劇終於發生了。某個店員不當心把店裏的某兩個價格牌給掛倒了。而且這兩個價格牌的電視機都賣出去了!
慶幸的是價格出入不大,其中一個價牌賠了2百多,另外一個價牌卻賺了8百多,綜合起來,反而多賺了558元。
請根據這些信息計算:賠錢的那個價牌正確的價格應該是多少?
答案是一個4位的整數,請經過瀏覽器直接提交該數字。
注意:不要提交解答過程,或其它輔助說明類的內容。
- package Forth;
-
- public class ReverseNumber {
-
-
-
-
- public int reverse(int n){
-
- int store[] = new int[4];
- int result = 0;
- int r;
- int i = 0;
-
- while( n != 0){
- r = n % 10;
- n = n / 10;
- store[i] = r;
- i++;
- }
- for(int k = 0; k < i; k++){
- if(store[k] == 3 || store[k] == 4 || store[k] == 7)
- return -1;
- else if(store[k] == 6)
- store[k] = 9;
- else if(store[k] == 9)
- store[k] = 6;
- }
- for(int j = 0; j < i; j++){
- if(store[0] == 0)
- return -1;
-
- if(j == 0)
- result = store[j];
- else
- result = result*10 +store[j];
- }
-
-
- return result;
- }
- public void selectNum(){
- int sub = 0;
- int sub2 = 0;
-
- for(int i = 1000; i <= 9999; i++){
-
- if(reverse(i) == -1)
- continue;
- sub = i-reverse(i);
-
- if(sub < 200 || sub >= 300)
- continue;
- for(int j = 1000; j <= 9999; j++){
-
- if(reverse(j) == -1)
- continue;
- sub2 = reverse(j)-j;
-
- if(sub2 < 800 || sub2 >= 900)
- continue;
- if((sub2-sub) == 558){
- System.out.println("賠錢的正確價格爲:"+i);
-
- }
- }
- }
-
- }
- }
答案:9088
轉載請標明出處:http://blog.csdn.net/u012027907