# 黎明高中資訊社第4次平時考
---
## 目錄:
> [TOC]
## 說明:
社長或副社長將從itsa或者zero judge挑選出4至5題的題目,基本上都不會選有出現在資訊社資源目錄的,難度隨題號遞增,在社團課抑或週六課程時將驗收,選擇自己會寫的先做,目前都是你們能夠解決的。
## 完成者填寫說明:
若已答題且正確完畢,請寫上自己的姓名,可以自己新增更多名次(如第一題有到11名,可以繼續增加),有空社長將抽查答對者的想法與程式,一切採自由心證,當然我回去看報表核對。
## 時間:
2020/06/25至2020/07/14 <9 p.m>
## 獎勵:
<font color="#f00">咕嚕靈波(●′∀‵)ノ♥</font>
## 前社長的話:
恰逢段考阿....
> [name=風思]
> [color=#f55f]
## 解答:
釋出。
---
### 1.<font color="#39FF33">[C_MM196-易] 麵包師傅</font>
#### =>[題目連結](https://e-tutor.itsa.org.tw/e-Tutor/mod/programming/view.php?id=8106)
#### 問題敘述:
某間麵包廠裡的麵包師傅每個人製作的速度都不一樣,老闆為了要分清楚每個師傅做麵包的速度,所以給每個人都給定量時間去計算出每人每天可以做出多少分。但是麵包如果做到一半是不能出貨的所以無條件捨去。
### 完成者:
1. <曾俊翔>
> [time=Thu, Jun 25, 2020 4:00 PM]
2. <張嘉元>
> [time=Thu, Jun 25, 2020 4:20 PM]
> 看到秒解
4. <吳品範>
> [time=Sat, Jun 27, 2020 9:57 AM]
5. <吳冠毅>
> [time=Sat, Jun 27, 2020 5:59 PM]
6. <柯昀杰>
> [time=Mon, Jul 13, 2020 8:27 PM]
#### 社長提供的測資:
無。
### 參考解答(前社長提供):
#### C:
```cpp=
#include <stdio.h>
int main(){
int x1,x2,y2,y1;
scanf("%d %d %d",&x1,&x2,&y2);
y1= (x1 * y2) / x2;
printf("%d\n",y1);
return 0;
}
```
### 參考解答(社員提供):
---
### 2.<font color="#E3FF33">[C_MM122-易] 計程車車資計算問題</font>
#### =>[題目連結](https://e-tutor.itsa.org.tw/e-Tutor/mod/programming/view.php?a=1450)
#### 問題敘述:
小嫻今天因為下雨,不想騎車上班,於是決定搭計程車的他開始詢問現在計程車價的行情,經過詢問後,他發現計程車只要不超過 1500 公尺的話都是以 70 塊計費,超過 1500 公尺後每 500 公尺跳一次費用,跳一次是加 5 塊錢,不滿 500 公尺的話還是以 500 公尺來計費。
### 完成者:
1. <曾俊翔>
> [time=Thu, Jun 25, 2020 4:03 PM]
2. <張嘉元>
> [time=Thu, Jun 25, 2020 4:26 PM]
3. <吳品範>
> [time=Sat, Jun 27, 2020 10:04 AM]
4. <吳冠毅>
> [time=Sat, Jun 27, 2020 5:58 PM]
5. <柯昀杰>
> [time=Mon, Jul 13, 2020 8:29 PM]
#### 社長提供的測資:
無。
### 參考解答(前社長提供):
#### Java:
```java=
import java.util.*;
//[C_MM122-易] 計程車車資計算問題
//2019,06,29;16:27
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int n = sc.nextInt();
// 感覺以後會看不懂
int sum = (n < 1500) ? 70 : 70 + 5 * ((n -1500) / 500) + ((n % 500 > 0) ? 5 : 0);
System.out.println(sum);
}
sc.close();
}
}
```
### 參考解答(社員提供):
---
### 3.<font color="#FF7433">[C_MM143-易] 求Emirp</font>
#### =>[題目連結](https://e-tutor.itsa.org.tw/e-Tutor/mod/programming/view.php?id=3589)
#### 問題敘述:
若一個質數同時其反向數也是一個質數,符合這樣特性的質數我們稱為 emirp 數。例如 17 是一個質數,同時 71 也是一個質數,所以 17 是一個 emirp 數。請寫一個程式可以顯示前 n 個 emirp 數。
### 完成者:
1. <曾俊翔>
> [time=Thu, Jun 25, 2020 4:05 PM]
2. <張嘉元>
> [time=Sun, Jun 28, 2020 10:39 AM]
> 搞好久 該死的emirp
#### 社長提供的測資:
無。
### 參考解答(前社長提供):
#### C:
```cpp=
#include <stdio.h>
#include <stdlib.h>
//[C_MM143-易] 求Emirp
//2019,09,10;22:19
int main(){
int n,count=0,isPrime=1,isEmirp=0,prime,reprime,emirp;
scanf("%d",&n);
int i,j,k;
for(i=2; 1; i++){
if(i%2==0&&i!=2)
continue;
isPrime=1;
isEmirp=0;
reprime=0;
emirp=0;
prime=0;
for(j=2; j<i/2 ; j++){
if(i%j==0){
isPrime=0;
continue;
}
}
if(isPrime){
prime=i;
isEmirp=1;
while(prime!=0){
reprime*=10;
reprime+=prime%10;
prime/=10;
}
for(k=2; k<reprime/2; k++){
if(reprime%k==0){
isEmirp=0;
continue;
}
}
if(isEmirp){
emirp=i;
printf("%d\n",emirp);
count++;
}
}
if(count==n)
break;
}
return 0;
}
```
### 參考解答(社員提供):
---
### 4.<font color="FF5233">[C_SL09-易] 霓虹燈泡</font>
#### =>[題目連結](https://e-tutor.itsa.org.tw/e-Tutor/mod/programming/view.php?id=1720)
#### 問題敘述:
一個大型霓虹燈由n個燈泡所組成,燈泡編號1至n。工程師設計霓虹燈的閃爍規則共分n個階段,第i個階段,編號是i的倍數的燈泡暗亮反相,也就是說燈泡本來是暗的變成亮的、亮的變成暗的。假設剛開始的時候所有的燈泡都是暗的。請問最後總共有幾個燈泡是亮的?
### 完成者:
1. <曾俊翔>
> [time=Thu, Jun 25, 2020 4:07 PM]
2. <張嘉元>
> [time=Sun, Jun 28, 2020 8:58 AM]
> 突然突破盲腸了
#### 社長提供的測資:
無。
### 參考解答(前社長提供):
#### C++:
```cpp=
#include <bits/stdc++.h>
using namespace std;
int main(){
int k,n,count;
scanf("%d",&k);
while(k--){
count=0;
scanf("%d",&n);
bool arr[n+1];
fill(arr,arr+n+1,0);
for(int i=1;i<=n;i++){
for(int j=i;j<=n;j+=i)
arr[j]=!arr[j];
}
for(int i=1;i<=n;i++){
if(arr[i])
count++;
}
printf("%d\n",count);
}
return 0;
}
```
### 參考解答(社員提供):
---
### 5.<font color="#f00">[C_SL14-易] 程式語法處理</font>
#### =>[題目連結](https://e-tutor.itsa.org.tw/e-Tutor/mod/programming/view.php?id=8073)
#### 問題敘述:
設計一程式,內建有 A 、 B 、 C 三個變數及 SET 、 CLEAR 、 ADD 、 SUB 、 SWAP 、 PRINT 六個語法,輸入 EXIT 則離開程式。
### 完成者:
1. <曾俊翔>
> [time=Thu, Jun 25, 2020 4:07 PM]
2. <李晨維>
> [time=Sat, Jun 27, 2020 9:53 AM]
> 然後舊judge又掛掉了
#### 社長提供的測資:
無。
### 參考解答(前社長提供):
#### C++:
```cpp=
#include <bits/stdc++.h>
using namespace std;
int main(){
size_t notfound =string::npos;
string str;
int A=0,B=0,C=0,temp=0;
while(cin >>str){
temp=0;
if(str.find("SET")!=notfound){
//cout << "SET" << endl;
if(str.at(6)>='A' and str.at(6)<='C'){
if(str.at(6)=='A')
temp=A;
else if(str.at(6)=='B')
temp=B;
else
temp=C;
}else{
for(int i=6;str.at(i)!=')';i++){
temp*=10;
temp+=str.at(i)-'0';
}
}
//cout << temp << endl;
if(str.at(4)=='A')
A=temp;
else if(str.at(4)=='B')
B=temp;
else if(str.at(4)=='C')
C=temp;
}else if(str.find("CLEAR")!=notfound){
//cout << "CLEAR" << endl;
if(str.at(6)=='A')
A=0;
else if(str.at(6)=='B')
B=0;
else if(str.at(6)=='C')
C=0;
}else if((str.find("ADD")!=notfound) or (str.find("SUB")!=notfound) ){
//cout << "ADD or SUB" << endl;
if(str.at(6)>='A' and str.at(6)<='C'){
if(str.at(6)=='A')
temp=A;
else if(str.at(6)=='B')
temp=B;
else
temp=C;
}else{
for(int i=6;str.at(i)!=')';i++){
temp*=10;
temp+=str.at(i)-'0';
}
}
if((str.find("SUB")!=notfound))
temp*=-1;
if(str.at(4)=='A')
A+=temp;
else if(str.at(4)=='B')
B+=temp;
else if(str.at(4)=='C')
C+=temp;
}else if((str.find("SWAP")!=notfound)){
//cout << "SWAP" << endl;
if(str.at(5)=='A' and str.at(7)=='B')
swap(A,B);
else if(str.at(5)=='A' and str.at(7)=='C')
swap(A,C);
else if(str.at(5)=='B' and str.at(7)=='C')
swap(B,C);
}else if((str.find("PRINT")!=notfound)){
cout << "A=" << A << endl;
cout << "B=" << B << endl;
cout << "C=" << C << endl;
}else if((str.find("EXIT")!=notfound))
break;
}
return 0;
}
```
### 參考解答(社員提供):
---
## <font color="#3AAA">統計表
| 第一題 | 第二題 | 第三題 | 第四題 | 第五題 | 全對者 |
|:------:|:------:|:------:|:------:|:------:|:------:|
| 6 | 5 | 2 | 2 | 2 | 1 |
---
###### tags: `社內考試`