2023年7月14日 星期五

ZeroJudge python解答:a021. 大數運算

       由於Python已經支援大數運算,所以程式碼就變得比較簡單。
print(eval(input().replace('/','//')))

經過測試,得到:
送出解答,得到:

資料來源:
1.高中生解題系統
 
ZeroJudge解題
ZeroJudge python解答:a004. 文文的求婚
ZeroJudge python解答:a005. Eva 的回家作業
ZeroJudge python解答:a006. 一元二次方程式
ZeroJudge python解答:a009. 解碼器
ZeroJudge python解答:a010. 因數分解
ZeroJudge python解答:a015. 矩陣的翻轉
ZeroJudge python解答:a017. 五則運算
ZeroJudge python解答:a020. 身分證檢驗
ZeroJudge python解答:a021. 大數運算
ZeroJudge python解答:a022. 迴文
ZeroJudge python解答:a024. 最大公因數(GCD)
ZeroJudge python解答:a034. 二進位制轉換
ZeroJudge python解答:a038. 數字翻轉
ZeroJudge python解答:a040. 阿姆斯壯數
ZeroJudge python解答:a042. 平面圓形切割
ZeroJudge python解答:a044. 空間切割
ZeroJudge python解答:a053. Sagit's 計分程式
ZeroJudge python解答:a054. 電話客服中心
ZeroJudge python解答:a058. MOD3
ZeroJudge python解答:a059. 完全平方
ZeroJudge python解答:a065. 提款卡密碼
ZeroJudge python解答:a104. 排序
ZeroJudge python解答:a121. 質數又來囉
ZeroJudge python解答:a148. You Cannot Pass?!
ZeroJudge python解答:a149. 乘乘樂
ZeroJudge python解答:a215. 明明愛數數
ZeroJudge python解答:a216. 數數愛明明
ZeroJudge python解答:a224. 明明愛明明
ZeroJudge python解答:a225. 明明愛排列
ZeroJudge python解答:a244. 新手訓練 ~ for + if
ZeroJudge python解答:a248. 新手訓練 ~ 陣列應用
ZeroJudge python解答:a263. 日期差幾天
ZeroJudge python解答:a410. 解方程
ZeroJudge python解答:a528. 大數排序
ZeroJudge python解答:a647. 投資專家
ZeroJudge python解答:a693. 吞食天地
ZeroJudge  python解答:a694. 吞食天地二
ZeroJudge python解答:a738. 最大公约数

 

 

2023年7月13日 星期四

ZeroJudge python解答:a020. 身分證檢驗

 a020. 身分證檢驗 - 高中生程式解題系統 (zerojudge.tw)

我的解答:

IDCard = list(input())
IDCity = {'A':10,'B':11,'C':12,'D':13,'E':14,'F':15,'G':16,'H':17,'I':34,
'J':18,'K':19,'L':20,'M':21,'N':22,'O':35,'P':23,'Q':24,'R':25,'S':26,
'T':27,'U':28,'V':29,'W':32,'X':30,'Y':31,'Z':33}
j = 9
sum = 0
for i in IDCard:
    if i in IDCity.keys():
        sum = sum + (IDCity[i]//10 +(IDCity[i]%10)*9)
    else:
        j = j - 1
        if j == 0:
            j=1
        sum = sum + int(i)*j

if sum%10 == 0:
    print('real')
else:
    print('fake')

經過測試,得到:

送出解答,得到:


資料來源:
1.高中生解題系統
 
ZeroJudge解題
ZeroJudge python解答:a004. 文文的求婚
ZeroJudge python解答:a005. Eva 的回家作業
ZeroJudge python解答:a006. 一元二次方程式
ZeroJudge python解答:a009. 解碼器
ZeroJudge python解答:a010. 因數分解
ZeroJudge python解答:a015. 矩陣的翻轉
ZeroJudge python解答:a017. 五則運算
ZeroJudge python解答:a020. 身分證檢驗
ZeroJudge python解答:a021. 大數運算
ZeroJudge python解答:a022. 迴文
ZeroJudge python解答:a024. 最大公因數(GCD)
ZeroJudge python解答:a034. 二進位制轉換
ZeroJudge python解答:a038. 數字翻轉
ZeroJudge python解答:a040. 阿姆斯壯數
ZeroJudge python解答:a042. 平面圓形切割
ZeroJudge python解答:a044. 空間切割
ZeroJudge python解答:a053. Sagit's 計分程式
ZeroJudge python解答:a054. 電話客服中心
ZeroJudge python解答:a058. MOD3
ZeroJudge python解答:a059. 完全平方
ZeroJudge python解答:a065. 提款卡密碼
ZeroJudge python解答:a104. 排序
ZeroJudge python解答:a121. 質數又來囉
ZeroJudge python解答:a148. You Cannot Pass?!
ZeroJudge python解答:a149. 乘乘樂
ZeroJudge python解答:a215. 明明愛數數
ZeroJudge python解答:a216. 數數愛明明
ZeroJudge python解答:a224. 明明愛明明
ZeroJudge python解答:a225. 明明愛排列
ZeroJudge python解答:a244. 新手訓練 ~ for + if
ZeroJudge python解答:a248. 新手訓練 ~ 陣列應用
ZeroJudge python解答:a263. 日期差幾天
ZeroJudge python解答:a410. 解方程
ZeroJudge python解答:a528. 大數排序
ZeroJudge python解答:a647. 投資專家
ZeroJudge python解答:a693. 吞食天地
ZeroJudge  python解答:a694. 吞食天地二
ZeroJudge python解答:a738. 最大公约数

 

 

2023年7月10日 星期一

ZeroJudge python解答:a017. 五則運算

       第一次看到這道題,發現一點感覺都沒有。只好趕緊找答案,沒想到要用到資料來源2.Python eval() 函数
我的解答:
import sys
for line in sys.stdin:
    if line != "\n":
        print(eval(line.replace('/','//')))
    else:
        break
經過測試執行,得到的結果為:
於是送出解答,得到

 
資料來源:
1.高中生解題系統
3.

ZeroJudge解題
ZeroJudge python解答:a004. 文文的求婚
ZeroJudge python解答:a005. Eva 的回家作業
ZeroJudge python解答:a006. 一元二次方程式
ZeroJudge python解答:a009. 解碼器
ZeroJudge python解答:a010. 因數分解
ZeroJudge python解答:a015. 矩陣的翻轉
ZeroJudge python解答:a017. 五則運算
ZeroJudge python解答:a020. 身分證檢驗
ZeroJudge python解答:a021. 大數運算
ZeroJudge python解答:a022. 迴文
ZeroJudge python解答:a024. 最大公因數(GCD)
ZeroJudge python解答:a034. 二進位制轉換
ZeroJudge python解答:a038. 數字翻轉
ZeroJudge python解答:a040. 阿姆斯壯數
ZeroJudge python解答:a042. 平面圓形切割
ZeroJudge python解答:a044. 空間切割
ZeroJudge python解答:a053. Sagit's 計分程式
ZeroJudge python解答:a054. 電話客服中心
ZeroJudge python解答:a058. MOD3
ZeroJudge python解答:a059. 完全平方
ZeroJudge python解答:a065. 提款卡密碼
ZeroJudge python解答:a104. 排序
ZeroJudge python解答:a121. 質數又來囉
ZeroJudge python解答:a148. You Cannot Pass?!
ZeroJudge python解答:a149. 乘乘樂
ZeroJudge python解答:a215. 明明愛數數
ZeroJudge python解答:a216. 數數愛明明
ZeroJudge python解答:a224. 明明愛明明
ZeroJudge python解答:a225. 明明愛排列
ZeroJudge python解答:a244. 新手訓練 ~ for + if
ZeroJudge python解答:a248. 新手訓練 ~ 陣列應用
ZeroJudge python解答:a263. 日期差幾天
ZeroJudge python解答:a410. 解方程
ZeroJudge python解答:a528. 大數排序
ZeroJudge python解答:a647. 投資專家
ZeroJudge python解答:a693. 吞食天地
ZeroJudge  python解答:a694. 吞食天地二
ZeroJudge python解答:a738. 最大公约数

 

 

2023年7月9日 星期日

ZeroJudge python解答:a015. 矩陣的翻轉(未完)

       要做本題之前,要先處理二維陣列。於是google大神找[python 二維陣列],就找到資料來源2.一維陣列與二維陣列(Python)。其中最為關鍵的是二維陣列的宣告:
score=[[0]*40 for i in range(5)]

我的第一次解答:
a = []
a = input().split(' ')
b = [[0] for i in range(int(a[0]))]
c = [[0]*int(a[1]) for i in range(int(a[0]))]
d = [[0]*int(a[0]) for i in range(int(a[1]))]
for i in range(int(a[0])):
    b[i] = input().split(' ')
    for j in range(int(a[1])):
        c[i][j] = int(b[i][j])
for i in range(int(a[0])):
    for j in range(int(a[1])):
        d[j][i] = c[i][j]

for i in range(int(a[1])):
    for j in range(int(a[0])):
        print(d[i][j],end=" ")
    print()

經過測試執行,得到的結果為:
心裡想:應該沒問題了。於是送出解答,卻得到:
仔細檢查,卻發現:


ZeroJudge解題
ZeroJudge python解答:a004. 文文的求婚
ZeroJudge python解答:a005. Eva 的回家作業
ZeroJudge python解答:a006. 一元二次方程式
ZeroJudge python解答:a009. 解碼器
ZeroJudge python解答:a010. 因數分解
ZeroJudge python解答:a015. 矩陣的翻轉
ZeroJudge python解答:a017. 五則運算
ZeroJudge python解答:a020. 身分證檢驗
ZeroJudge python解答:a021. 大數運算
ZeroJudge python解答:a022. 迴文
ZeroJudge python解答:a024. 最大公因數(GCD)
ZeroJudge python解答:a034. 二進位制轉換
ZeroJudge python解答:a038. 數字翻轉
ZeroJudge python解答:a040. 阿姆斯壯數
ZeroJudge python解答:a042. 平面圓形切割
ZeroJudge python解答:a044. 空間切割
ZeroJudge python解答:a053. Sagit's 計分程式
ZeroJudge python解答:a054. 電話客服中心
ZeroJudge python解答:a058. MOD3
ZeroJudge python解答:a059. 完全平方
ZeroJudge python解答:a065. 提款卡密碼
ZeroJudge python解答:a104. 排序
ZeroJudge python解答:a121. 質數又來囉
ZeroJudge python解答:a148. You Cannot Pass?!
ZeroJudge python解答:a149. 乘乘樂
ZeroJudge python解答:a215. 明明愛數數
ZeroJudge python解答:a216. 數數愛明明
ZeroJudge python解答:a224. 明明愛明明
ZeroJudge python解答:a225. 明明愛排列
ZeroJudge python解答:a244. 新手訓練 ~ for + if
ZeroJudge python解答:a248. 新手訓練 ~ 陣列應用
ZeroJudge python解答:a263. 日期差幾天
ZeroJudge python解答:a410. 解方程
ZeroJudge python解答:a528. 大數排序
ZeroJudge python解答:a647. 投資專家
ZeroJudge python解答:a693. 吞食天地
ZeroJudge  python解答:a694. 吞食天地二
ZeroJudge python解答:a738. 最大公约数

 

 

2023年7月2日 星期日

ZeroJudge python解答:a216. 數數愛明明

       問題:題目中有個關鍵,那就是[python如何實現對文件結束符(EOF)的判斷]
我決定用sys.stdin來處理這道題:
import sys
for line in sys.stdin:
    if line != "\n":
   
    else:
        break

我的最新解答:參考資料來源4.使用迴圈產生費波那契數列,利用迴圈來寫,發現可以通過。

import sys
for line in sys.stdin:
    if line != "\n":
        n = int(line)
        funf = []
        farr = []
        fung = []
        garr = []
        for i in range(1,n+1):
            if i == 1:
                f = 1
                g = 1
                funf.append(f)
                farr.append(f)
                fung.append(g)
                garr.append(g)
            else:
                f = i+funf[0]
                g = f+fung[0]
                del funf[0]
                del fung[0]
                funf.append(f)
                fung.append(g)
            farr.append(f)
            garr.append(g)
        print(farr[n],garr[n])
    else:
        break

測試後結果:


我的第一次解答:參考資料來源3.運用遞迴產生費波那契數列,採用遞迴的方式來寫,發現只能得50%

import sys

def funf(n):
    if n > 1:
        return n + funf(n-1)
    return 1

def fung(n):
    if n > 1:
        return funf(n)+fung(n-1)
    return 1

for line in sys.stdin:
    if line != "\n":
        ln = int(line)
        print(funf(ln),fung(ln))
    else:
        break

測試後結果:




資料來源:
1.高中生解題系統
2.python如何實現對文件結束符(EOF)的判斷
3.運用遞迴產生費波那契數列



ZeroJudge解題
ZeroJudge python解答:a004. 文文的求婚
ZeroJudge python解答:a005. Eva 的回家作業
ZeroJudge python解答:a006. 一元二次方程式
ZeroJudge python解答:a009. 解碼器
ZeroJudge python解答:a010. 因數分解
ZeroJudge python解答:a015. 矩陣的翻轉
ZeroJudge python解答:a017. 五則運算
ZeroJudge python解答:a020. 身分證檢驗
ZeroJudge python解答:a021. 大數運算
ZeroJudge python解答:a022. 迴文
ZeroJudge python解答:a024. 最大公因數(GCD)
ZeroJudge python解答:a034. 二進位制轉換
ZeroJudge python解答:a038. 數字翻轉
ZeroJudge python解答:a040. 阿姆斯壯數
ZeroJudge python解答:a042. 平面圓形切割
ZeroJudge python解答:a044. 空間切割
ZeroJudge python解答:a053. Sagit's 計分程式
ZeroJudge python解答:a054. 電話客服中心
ZeroJudge python解答:a058. MOD3
ZeroJudge python解答:a059. 完全平方
ZeroJudge python解答:a065. 提款卡密碼
ZeroJudge python解答:a104. 排序
ZeroJudge python解答:a121. 質數又來囉
ZeroJudge python解答:a148. You Cannot Pass?!
ZeroJudge python解答:a149. 乘乘樂
ZeroJudge python解答:a215. 明明愛數數
ZeroJudge python解答:a216. 數數愛明明
ZeroJudge python解答:a224. 明明愛明明
ZeroJudge python解答:a225. 明明愛排列
ZeroJudge python解答:a244. 新手訓練 ~ for + if
ZeroJudge python解答:a248. 新手訓練 ~ 陣列應用
ZeroJudge python解答:a263. 日期差幾天
ZeroJudge python解答:a410. 解方程
ZeroJudge python解答:a528. 大數排序
ZeroJudge python解答:a647. 投資專家
ZeroJudge python解答:a693. 吞食天地
ZeroJudge  python解答:a694. 吞食天地二
ZeroJudge python解答:a738. 最大公约数

 

 

ZeroJudge python解答:a215. 明明愛數數


 
        問題:題目中有個關鍵,那就是[python如何實現對文件結束符(EOF)的判斷]
我決定用sys.stdin來處理這道題:
import sys
for line in sys.stdin:
    if line != "\n":
   
    else:
        break 

我的解答:

import sys
for line in sys.stdin:
    if line !="\n":
        ln,lm = line.split(" ")
        n = int(ln)
        m = int(lm)
        sum = n
        k = 1
        while sum <= m:
            n = n + 1
            sum = sum + n
            k = k + 1
        print(k)
    else:
        break

測試後結果:

資料來源:
1.高中生解題系統
2.python如何實現對文件結束符(EOF)的判斷

 


ZeroJudge解題
ZeroJudge python解答:a004. 文文的求婚
ZeroJudge python解答:a005. Eva 的回家作業
ZeroJudge python解答:a006. 一元二次方程式
ZeroJudge python解答:a009. 解碼器
ZeroJudge python解答:a010. 因數分解
ZeroJudge python解答:a015. 矩陣的翻轉
ZeroJudge python解答:a017. 五則運算
ZeroJudge python解答:a020. 身分證檢驗
ZeroJudge python解答:a021. 大數運算
ZeroJudge python解答:a022. 迴文
ZeroJudge python解答:a024. 最大公因數(GCD)
ZeroJudge python解答:a034. 二進位制轉換
ZeroJudge python解答:a038. 數字翻轉
ZeroJudge python解答:a040. 阿姆斯壯數
ZeroJudge python解答:a042. 平面圓形切割
ZeroJudge python解答:a044. 空間切割
ZeroJudge python解答:a053. Sagit's 計分程式
ZeroJudge python解答:a054. 電話客服中心
ZeroJudge python解答:a058. MOD3
ZeroJudge python解答:a059. 完全平方
ZeroJudge python解答:a065. 提款卡密碼
ZeroJudge python解答:a104. 排序
ZeroJudge python解答:a121. 質數又來囉
ZeroJudge python解答:a148. You Cannot Pass?!
ZeroJudge python解答:a149. 乘乘樂
ZeroJudge python解答:a215. 明明愛數數
ZeroJudge python解答:a216. 數數愛明明
ZeroJudge python解答:a224. 明明愛明明
ZeroJudge python解答:a225. 明明愛排列
ZeroJudge python解答:a244. 新手訓練 ~ for + if
ZeroJudge python解答:a248. 新手訓練 ~ 陣列應用
ZeroJudge python解答:a263. 日期差幾天
ZeroJudge python解答:a410. 解方程
ZeroJudge python解答:a528. 大數排序
ZeroJudge python解答:a647. 投資專家
ZeroJudge python解答:a693. 吞食天地
ZeroJudge  python解答:a694. 吞食天地二
ZeroJudge python解答:a738. 最大公约数

 

 

ZeroJudge python解答:a149. 乘乘樂

 

我的解答:
T = int(input())
for i in range(T):
    NumStr = input()
    Num = int(NumStr)
    digits = len(NumStr)
    product = 1
    for j in range(digits):
        if j == 0:
            product = product * (Num%10)
        elif j == digits-1:
            product = product * (Num//(10**j))
        else:
            product = product * (Num//(10**j)%10)
    print(product)
測試後結果:

資料來源:
1.高中生解題系統
2.

ZeroJudge解題
ZeroJudge  python解答:a001. 哈囉

ZeroJudge python解答:a004. 文文的求婚
ZeroJudge python解答:a005. Eva 的回家作業
ZeroJudge python解答:a006. 一元二次方程式
ZeroJudge python解答:a009. 解碼器
ZeroJudge python解答:a010. 因數分解
ZeroJudge python解答:a015. 矩陣的翻轉
ZeroJudge python解答:a017. 五則運算
ZeroJudge python解答:a020. 身分證檢驗
ZeroJudge python解答:a021. 大數運算
ZeroJudge python解答:a022. 迴文
ZeroJudge python解答:a024. 最大公因數(GCD)
ZeroJudge python解答:a034. 二進位制轉換
ZeroJudge python解答:a038. 數字翻轉
ZeroJudge python解答:a040. 阿姆斯壯數
ZeroJudge python解答:a042. 平面圓形切割
ZeroJudge python解答:a044. 空間切割
ZeroJudge python解答:a053. Sagit's 計分程式
ZeroJudge python解答:a054. 電話客服中心
ZeroJudge python解答:a058. MOD3
ZeroJudge python解答:a059. 完全平方
ZeroJudge python解答:a065. 提款卡密碼
ZeroJudge python解答:a104. 排序
ZeroJudge python解答:a121. 質數又來囉
ZeroJudge python解答:a148. You Cannot Pass?!
ZeroJudge python解答:a149. 乘乘樂
ZeroJudge python解答:a215. 明明愛數數
ZeroJudge python解答:a216. 數數愛明明
ZeroJudge python解答:a224. 明明愛明明
ZeroJudge python解答:a225. 明明愛排列
ZeroJudge python解答:a244. 新手訓練 ~ for + if
ZeroJudge python解答:a248. 新手訓練 ~ 陣列應用
ZeroJudge python解答:a263. 日期差幾天
ZeroJudge  python解答:a694. 吞食天地二
ZeroJudge python解答:a738. 最大公约数
 





ZeroJudge python解答:a271. 彩色蘿蔔

  a271. 彩色蘿蔔 我的解法: 這題的重點只有兩個: 每天早上先扣中毒效果,再吃蘿蔔 中毒可累加,而且吃到黑蘿蔔當天不扣毒,從隔天開始扣 t = int ( input ()) for i in range ( t ):     x , y , z ,...