【PAT-A】1058. A+B in Hogwarts 寫題記錄
#include <cstdio> struct man{ int G; //[0,10^7] int S; //[0,17) int K; //[0,29) }A,B; int main(){ int count=0; scanf("%d.%d.%d",&A.G,&A.S,&A.K); scanf("%d.%d.%d",&B.G,&B.S,&B.K); int TK=(A.K+B.K) % 29; count =(A.K+B.K) / 29; int TS= (A.S+B.S+count) %17; count = (A.S+B.S+count) / 17; int TG=A.G+B.G+count; printf("%ld.%d.%d",TG,TS,TK); }
相關推薦
【PAT-A】1058. A+B in Hogwarts 寫題記錄
#include <cstdio> struct man{ int G; //[0,10^7] int S; //[0,17) int K; //[0,29) }A,B; int main(){ int count=0; scanf("%d.%d.%d",&A.G,&a
【PAT甲級】1002 A+B for Polynomials
This time, you are supposed to find A+B where A and B are two polynomials. Input Specification: Each input file cont
【PAT甲級】1001 A+B Format
Calculate a+b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there ar
【PAT-A】1027. Colors in Mars 寫題記錄
進位制轉換問題,多了個數字轉英文 #include <cstdio> const int radix = 13; const char radixchart[13]={'0','1','2','3','4','5','6','7','8','9','A','B','C'}; void
【PAT-A】1002. A+B for Polynomials 寫題記錄
思路: 第一次輸入原樣輸入,第二次輸入時,直接將相同指數的係數相加,並查詢有沒有已存在的指數,統計係數為0的個數。 因為佇列無法直接刪除係數為0的項,故0項最後輸出的時候再處理。 注意最後的格式 PS.題目有個瑕疵,未說明指數是否按降序輸入與輸出,因此最開始構思時想的是用優先佇列。
PAT 甲級 1058 A+B in Hogwarts [Java實現]
1. 題意 也是進位制轉換的題目 兩個數字相加,然後第二項是17進位制,第三項是29進位制 2. 思路 水題。 注意最高位沒有進位限制,一開始被這個坑了。 3. 程式碼 package adv1058; import java.io.BufferedReader;
【PAT-A】1001. A+B Format 寫題記錄
思路: 結果c預先判斷,等於零則直接輸出,小於零則先輸出“-”,再按大於零處理。 之後用棧來處理,如果陣列長度是3的倍數且大於3,就輸出逗號。最後3位單獨處理,直接輸出。 #include <cstdio> #include <stack> us
PAT 1058 A+B in Hogwarts (20 分)
1058 A+B in Hogwarts (20 分) If you are a fan of Harry Potter, you would know the world of magic has its own currency system – as Ha
PAT (Advanced Level) Practice 1058 A+B in Hogwarts (20 分) (C++)(甲級)
1058 A+B in Hogwarts (20 分) If you are a fan of Harry Potter, you would know the world of magic has its own currency system – as Hagrid explai
【PAT 甲級】1151 LCA in a Binary Tree (30 分)
lca osi 我不知道 pri lin nes %d sed father 題目描述 The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has
1058. A+B in Hogwarts (20)
you turn fan explained names world printf blog tput If you are a fan of Harry Potter, you would know the world of magic has its own curre
【FZU - 1759】Super A^B mod C (數論,快速冪,快速乘,尤拉降冪,指數迴圈節,模板)
題幹: Given A,B,C, You should quickly calculate the result of A^B mod C. (1<=A,C<=1000000000,1<=B<=10^1000000). Input There are mult
PAT-ADVANCED1058——A+B in Hogwarts
我的PAT-ADVANCED程式碼倉:https://github.com/617076674/PAT-ADVANCED 原題連結:https://pintia.cn/problem-sets/994805342720868352/problems/994805416519647232
1058 A+B in Hogwarts
題目大意: 1 Galleon=17 Sickle,1 Sickle=29 Knut。計算A+B。 解題思路: 模擬。 程式碼如下: #include<iostream> #include<cstdio> #include<fstrea
【PAT-A】1077. Kuchiguse 寫題記錄
這一題碰到最麻煩的一點是無法用gets()直接讀取一整行,使用fget()怕出問題,所以想著如何用scanf()解決。 scanf(%s) 無法讀入空格,但是可以利用正則來解決,scanf(%[^\n])可以讀入非換行符的所有字元,但如果不加getchar(),則緩衝區裡一直有 \n,接下來的字
【PAT-A】1073. Scientific Notation 寫題記錄
寫題的時候沒看見整數部分從1-9,考慮了0的情況,寫了很多版本,選了個最精簡的。 #include <cstdio> #include <cstring> int main(){ char input[10010]; scanf("%s",&input);
【PAT-A】1046. Shortest Distance 寫題記錄
思路: 輸入時計算dis與sum,dis[i]表示 Vi到V1的距離,此時會有dis[N+1]出現,不去理他,1到N的距離不被儲存,但無所謂,因為sum-dis[N]即是。計算a、b距離時,dis[a]-dis[b]即可。 注意不能記錄各相鄰點的距離,來相加臨時算a、b的距離,會超時。
【PAT-A】1042. Shuffling Machine 寫題記錄
思路: 設定start[55],end[55]兩個陣列,每一變化以後,end 覆蓋start 然後迴圈。Sx,Dx、Hx、Cx、Jx等等可以依照次序來獲得,沒必要原樣建立55個,直接改變,這樣需要用到strcpy。注意次序和編碼的關係。 #include <cstdio> #i
【PAT-A】1005. Spell It Right 寫題記錄
思路: 每次讀入一位數,計算sum,最後提取sum的每一位,轉成英文輸出。 注意N<10^100,N不能是int、Long等型別,最好將其當做字元,用getchar(),每一位每一位地輸入。可知9*100=900,sum最多3位。 #include <cstdio> #
【PAT-A】1004. Counting Leaves 寫題記錄
思路: 一看題我想到的就是想構樹,然後層序遍歷,每層遍歷完輸出一次。 但題目給的例子非常簡單,有疑問的是,輸入的時候不知道結點是否是按ID的次序輸入的,若是按照次序輸入,一路構建下來就很容易了,若不是按照次序,我的思路是等所有M個子樹都構建完畢,記錄子樹根結點的地址、ID,然後從ID為1的根