# UVa 11879 ### 題述:給定一正整數 n,請你判斷 n 是否為17的倍數。 #### 最多有十組測試資料,每組一列為一個整數n( 1<=n<=10100),當n=0表示資料結束。 #### :warning:大數 :::info **Tips**:用 ***string*** or ***char*** 存 ::: ### c++ code: ```cpp= #include <bits/stdc++.h> using namespace std; int main () { string n; while(cin>>n) { int a = 0 ; if (n == "0" && n.size() == 1) { break; } else { for (int i = 0 ; i < n.size() ; i++ ) { a = (a * 10 + n[i] - '0') % 17 } if (a == 0) { cout << "1" << endl ; } else { cout << "0" << endl ; } } } } ``` :::success **``sample input``** 34 201 2909876 1717171717171717171717171717171717171717171717171718 0 ::: :::success **``sample output``** 1 0 1 0 ::: #### [返回首頁](https://hackmd.io/@fkleofk/APCS#11879) ###### tags: `APCS選修` `C++` `UVa`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up