|
1樓 巨大八爪鱼
2015-11-17 23:55
題目標題: 高斯日記
大數學家高斯有個好習慣:無論如何都要記日記。
他的日記有個與眾不同的地方,他從不註明年月日,而是用一個整數代替,比如:4210
後來人們知道,那個整數就是日期,它表示那一天是高斯出生後的第幾天。這或許也是個好習慣,它時時刻刻提醒著主人:日子又過去一天,還有多少時光可以用於浪費呢?
高斯出生於:1777年4月30日。 在高斯發現的一個重要定理的日記上標註著:5343,因此可算出那天是:1791年12月15日。
高斯獲得博士學位的那天日記上標著:8113
請你算出高斯獲得博士學位的年月日。
提交答案的格式是:yyyy-mm-dd, 例如:1980-03-21
請嚴格按照格式,通過瀏覽器提交答案。 注意:只提交這個日期,不要寫其它附加內容,比如:說明性的文字。
|
|
2樓 巨大八爪鱼
2015-11-17 23:56
【編寫的VS2012 C程序】 // Match.cpp : Defines the entry point for the console application. //
#include "stdafx.h" #include <stdio.h> #include <conio.h>
void checkLeapYear(int *daynum, const int year) { if ((year % 100 != 0 && year % 4 == 0) || (year % 100 == 0 && year % 400 == 0)) *daynum = 29; else *daynum = 28; }
void cal(const int num) { int daynum[] = {0, 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int year = 1777; int month = 4; int day = 30; int i = num - 1; // 1777-4-30 is his first day checkLeapYear(&daynum[2], year); while (i--) { day++; if (day > daynum[month]) { day = 1; month++; if (month > 12) { month = 1; year++; checkLeapYear(&daynum[2], year); } } } printf("Day %d: %4d-%02d-%02d\n", num, year, month, day); }
int _tmain(int argc, _TCHAR* argv[]) { cal(1); cal(3); cal(5343); cal(8113); _getch(); return 0; } 【運行結果】 Day 1: 1777-04-30 Day 3: 1777-05-02 Day 5343: 1791-12-15 Day 8113: 1799-07-16
|
|
3樓 巨大八爪鱼
2015-11-17 23:59
VS2012把C語言修改了很多,比如禁止使用標準的sprintf、scanf和getch函數,而且還有#include "stdafx.h"這句話禁止刪除(除非創建的是空工程),main主函數的名字也被改成了_tmain,默認運行控制台程序時窗口一閃而過,必須手動加_getch();等。 因此,編寫程序時,最好採用大賽所推薦的Dev-C++開發環境(使用的是GNU的gcc編譯器)
|
|
4樓 巨大八爪鱼
2015-11-18 00:02
標題: 馬虎的算式
小明是個急性子,上小學的時候經常把老師寫在黑板上的題目抄錯了。
有一次,老師出的題目是:36 x 495 = ?
他卻給抄成了:396 x 45 = ?
但結果卻很戲劇性,他的答案竟然是對的!!
因為 36 * 495 = 396 * 45 = 17820
類似這樣的巧合情況可能還有很多,比如:27 * 594 = 297 * 54
假設 a b c d e 代表1~9不同的5個數字(注意是各不相同的數字,且不含0)
能滿足形如: ab * cde = adb * ce 這樣的算式一共有多少種呢?
請你利用計算機的優勢尋找所有的可能,並回答不同算式的種類數。
滿足乘法交換律的算式計為不同的種類,所以答案肯定是個偶數。
答案直接通過瀏覽器提交。 注意:只提交一個表示最終統計種類數的數字,不要提交解答過程或其它多餘的內容。
|
|
5樓 巨大八爪鱼
2015-11-19 23:17
回復:4樓 由於C語言對1~9這九個數作A(5, 9)排列十分複雜(光是做全排A9,9都十分複雜,還別說挑五個出來作排列了!,參見: https://zh.arslanbar.net/post.php?t=23414),所以可以換個方式,用for循環讓變數i從12345開始一直計到98765,每次循環都檢查這五個數字是否互不相同,如果有兩個數字是相同就continue,否則就檢查是否滿足ab * cde = adb * ce,滿足則輸出這個算式。
|
|
6樓 巨大八爪鱼
2015-11-19 23:32
#include <stdio.h>
int main() { int num, i, j, flag; int digits[5]; int ab, cde, adb, ce; int count = 0; for (num = 12345; num <= 98765; num++) { digits[4] = num / 10000; digits[3] = num % 10000 / 1000; digits[2] = num % 1000 / 100; digits[1] = num % 100 / 10; digits[0] = num % 10; flag = 0; for (i = 0; i < 5; i++) { if (digits[i] == 0) { // 0 is forbidden flag = 1; break; } for (j = i + 1; j < 5; j++) { if (digits[i] == digits[j]) { flag = 1; break; } } if (flag == 1) break; } if (flag == 1) continue; ab = digits[4] * 10 + digits[3]; cde = digits[2] * 100 + digits[1] * 10 + digits[0]; adb = digits[4] * 100 + digits[1] * 10 + digits[3]; ce = digits[2] * 10 + digits[0]; if (ab * cde == adb * ce) { count++; printf("%d * %d = %d * %d = %d\n", ab, cde, adb, ce, ab * cde); } } printf("Count: %d\n", count); return 0; } 【運行結果】 14 * 253 = 154 * 23 = 3542 14 * 352 = 154 * 32 = 4928 14 * 536 = 134 * 56 = 7504 14 * 938 = 134 * 98 = 13132 15 * 264 = 165 * 24 = 3960 15 * 462 = 165 * 42 = 6930 16 * 238 = 136 * 28 = 3808 16 * 275 = 176 * 25 = 4400 16 * 294 = 196 * 24 = 4704 16 * 374 = 176 * 34 = 5984 16 * 392 = 196 * 32 = 6272 16 * 473 = 176 * 43 = 7568 16 * 572 = 176 * 52 = 9152 17 * 286 = 187 * 26 = 4862 17 * 385 = 187 * 35 = 6545 17 * 394 = 197 * 34 = 6698 17 * 583 = 187 * 53 = 9911 17 * 682 = 187 * 62 = 11594 18 * 297 = 198 * 27 = 5346 18 * 396 = 198 * 36 = 7128 18 * 495 = 198 * 45 = 8910 18 * 594 = 198 * 54 = 10692 18 * 693 = 198 * 63 = 12474 18 * 792 = 198 * 72 = 14256 23 * 154 = 253 * 14 = 3542 23 * 451 = 253 * 41 = 10373 24 * 165 = 264 * 15 = 3960 24 * 196 = 294 * 16 = 4704 24 * 561 = 264 * 51 = 13464 24 * 936 = 234 * 96 = 22464 25 * 176 = 275 * 16 = 4400 25 * 374 = 275 * 34 = 9350 25 * 473 = 275 * 43 = 11825 25 * 671 = 275 * 61 = 16775 26 * 187 = 286 * 17 = 4862 26 * 385 = 286 * 35 = 10010 26 * 583 = 286 * 53 = 15158 26 * 781 = 286 * 71 = 20306 27 * 198 = 297 * 18 = 5346 27 * 396 = 297 * 36 = 10692 27 * 495 = 297 * 45 = 13365 27 * 594 = 297 * 54 = 16038 27 * 693 = 297 * 63 = 18711 27 * 891 = 297 * 81 = 24057 28 * 136 = 238 * 16 = 3808 28 * 469 = 268 * 49 = 13132 28 * 596 = 298 * 56 = 16688 32 * 154 = 352 * 14 = 4928 32 * 196 = 392 * 16 = 6272 32 * 451 = 352 * 41 = 14432 34 * 176 = 374 * 16 = 5984 34 * 197 = 394 * 17 = 6698 34 * 275 = 374 * 25 = 9350 34 * 572 = 374 * 52 = 19448 34 * 591 = 394 * 51 = 20094 34 * 671 = 374 * 61 = 22814 35 * 187 = 385 * 17 = 6545 35 * 286 = 385 * 26 = 10010 35 * 682 = 385 * 62 = 23870 35 * 781 = 385 * 71 = 27335 36 * 198 = 396 * 18 = 7128 36 * 297 = 396 * 27 = 10692 36 * 495 = 396 * 45 = 17820 36 * 594 = 396 * 54 = 21384 36 * 792 = 396 * 72 = 28512 36 * 891 = 396 * 81 = 32076 38 * 597 = 398 * 57 = 22686 38 * 796 = 398 * 76 = 30248 41 * 253 = 451 * 23 = 10373 41 * 352 = 451 * 32 = 14432 42 * 165 = 462 * 15 = 6930 42 * 561 = 462 * 51 = 23562 43 * 176 = 473 * 16 = 7568 43 * 275 = 473 * 25 = 11825 43 * 572 = 473 * 52 = 24596 43 * 671 = 473 * 61 = 28853 45 * 198 = 495 * 18 = 8910 45 * 297 = 495 * 27 = 13365 45 * 396 = 495 * 36 = 17820 45 * 693 = 495 * 63 = 31185 45 * 792 = 495 * 72 = 35640 45 * 891 = 495 * 81 = 40095 49 * 268 = 469 * 28 = 13132 51 * 264 = 561 * 24 = 13464 51 * 394 = 591 * 34 = 20094 51 * 462 = 561 * 42 = 23562 52 * 176 = 572 * 16 = 9152 52 * 374 = 572 * 34 = 19448 52 * 473 = 572 * 43 = 24596 52 * 671 = 572 * 61 = 34892 52 * 931 = 532 * 91 = 48412 53 * 187 = 583 * 17 = 9911 53 * 286 = 583 * 26 = 15158 53 * 682 = 583 * 62 = 36146 53 * 781 = 583 * 71 = 41393 54 * 198 = 594 * 18 = 10692 54 * 297 = 594 * 27 = 16038 54 * 396 = 594 * 36 = 21384 54 * 693 = 594 * 63 = 37422 54 * 792 = 594 * 72 = 42768 54 * 891 = 594 * 81 = 48114 56 * 134 = 536 * 14 = 7504 56 * 298 = 596 * 28 = 16688 56 * 894 = 596 * 84 = 50064 56 * 938 = 536 * 98 = 52528 57 * 398 = 597 * 38 = 22686 61 * 275 = 671 * 25 = 16775 61 * 374 = 671 * 34 = 22814 61 * 473 = 671 * 43 = 28853 61 * 572 = 671 * 52 = 34892 62 * 187 = 682 * 17 = 11594 62 * 385 = 682 * 35 = 23870 62 * 583 = 682 * 53 = 36146 62 * 781 = 682 * 71 = 48422 63 * 198 = 693 * 18 = 12474 63 * 297 = 693 * 27 = 18711 63 * 495 = 693 * 45 = 31185 63 * 594 = 693 * 54 = 37422 63 * 792 = 693 * 72 = 49896 63 * 891 = 693 * 81 = 56133 71 * 286 = 781 * 26 = 20306 71 * 385 = 781 * 35 = 27335 71 * 583 = 781 * 53 = 41393 71 * 682 = 781 * 62 = 48422 72 * 198 = 792 * 18 = 14256 72 * 396 = 792 * 36 = 28512 72 * 495 = 792 * 45 = 35640 72 * 594 = 792 * 54 = 42768 72 * 693 = 792 * 63 = 49896 72 * 891 = 792 * 81 = 64152 76 * 398 = 796 * 38 = 30248 81 * 297 = 891 * 27 = 24057 81 * 396 = 891 * 36 = 32076 81 * 495 = 891 * 45 = 40095 81 * 594 = 891 * 54 = 48114 81 * 693 = 891 * 63 = 56133 81 * 792 = 891 * 72 = 64152 84 * 596 = 894 * 56 = 50064 91 * 532 = 931 * 52 = 48412 96 * 234 = 936 * 24 = 22464 98 * 134 = 938 * 14 = 13132 98 * 536 = 938 * 56 = 52528 Count: 142
|
|
7樓 巨大八爪鱼
2015-11-19 23:44
回復:6樓 這個程序我寫了15分鐘。 所以在競賽時,時間控制很重要。。。
|
|
8樓 巨大八爪鱼
2015-11-21 20:59
第七屆藍橋杯全國軟體和信息技術專業人才大賽 賽程安排
個人賽報名時間:2015年10月到2015年12月15日截止
省賽時間:2016年3月
省賽地點:各分賽區指定賽點學校。
國賽(全國總決賽)時間:2016年5月
國賽競賽地點:暫定北京
|
|
忽然發現DEV-C不會用啊啊
|
|
|