Author:mystery
time:2024/7/12
---
* 建議重新寫過題目!!!
* 真的不會寫,再打開code參考
# neoj
## 小蘋果
* 網址
* https://neoj.sprout.tw/problem/602/
* hint:
* 先求平均,再爆搜所有蘋果重量,低於平均重量的蘋果相加
:::spoiler code
```cpp=
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;cin>>n;
int apple[n],sum=0;
for(int i=0;i<n;i++)
{
cin>>apple[i];
sum += apple[i];
}
sum /=n;
int ans=0;
for(int i=0;i<n;i++)
{
if(sum>apple[i])
{
ans += apple[i];
}
}
cout<<ans;
}
```
:::
## σ.σ - 2015
* 網址
* https://neoj.sprout.tw/problem/209/
* hint:
* 輸出a的第a0的數字
:::spoiler code
```cpp=
#include<bits/stdc++.h>
using namespace std;
int main()
{
cin.sync_with_stdio(0);//io優化
cin.tie(0);
int n;cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
for(int i=0;i<n;i++)
{
cout<<a[a[i]]<<endl;
}
}
```
:::
## Sproutle
* 網址
* https://neoj.sprout.tw/problem/988/
* hint
* 比對猜測答案字母,找到完全正確答案時退出迴圈
:::spoiler code
```cpp=
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
int main()
{
/*
A g ans&pos
B y ans
C gray 0
*/
cin.sync_with_stdio(0);//io優化
cin.tie(0);
string ans,chr;
cin>>ans;
int ans_size = ans.size();
while(cin>>chr && chr != ans)//重複輸入猜測答案,並判斷猜測答案是否正確
{
for(int i=0; i<ans_size; i++)//判斷猜測字母屬性
{
for(int j=0; j<ans_size; j++)
{
if(chr[i] == ans[j])
{
if(i == j)//i,j分別代表ans,chr存在位置
{
cout<<"A";
break;
}
else
{
cout<<"B";
break;
}
}
if(j == ans_size-1)//完全不存在則輸出C
{
cout<<"C";
break;
}
}
}
cout<<endl;
}
for(int i=0;i<ans_size;i++)
{
cout<<"A";
}
cout<<endl;//系統最後要輸出換行(爛judge,害我debug超久= =
}
```
:::
---
# zerojudge
## a147. Print it all
* 網址
* https://zerojudge.tw/ShowProblem?problemid=a147
* hint:
* 輸出%7不為0的數
:::spoiler code
```cpp=
#include <bits/stdc++.h>
using namespace std;
/*void f(int n)
{
for(int i=1;i<n;i++)
{
if(i%7)
cout<<i<<" ";
}
cout<<endl;
}*/
int main()
{
int n;
while(cin>>n)
{
for(int i=1;i<n;i++)
{
if(i%7)
cout<<i<<" ";
}
cout<<endl;
}
}
```
:::
## a215. 明明愛數數
* 網址
* https://zerojudge.tw/ShowProblem?problemid=a215
* hint
* n,m可能為負數
:::spoiler code
```cpp=
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
while(cin>>n>>m)
{
int ans=0,point=0;
for(int i=n;;i++)
{
ans +=i;
point++;
if(ans>m)
{
break;
}
}
cout<<point<<endl;
}
}
```
:::
# 比賽題
* 因為平台設置於學校內網,只有連接學校網路才能進入,所以沒有檢測平台
## 第八題
```cpp=
#include<iostream>
using namespace std;
int main(){
int n,m;
cin>>n>>m;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
//向右
int sum=0;
int home=a[m-1];
int tall=a[m];
for(int i=m;i<n;i++){
if(a[i]>=tall&&a[i]>home){
sum++;
}
if(a[i]>tall){
tall=a[i];
}
}
//左
tall=a[m-2];
for(int i=m-2;i>=0;i--){
if(a[i]>=tall&&a[i]>home){
sum++;
}
if(a[i]>tall){
tall=a[i];
}
}
cout<<sum<<endl;
return 0;
}
```
## 第九題
```cpp=
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,b,w,ww;
cin >> n;
int e,f,c;
for(int i=0;i<n;i++)
{
b=0;
w=0;
cin>>e>>f>>c;
b=e+f;
w=b/c;
b=(b%c)+w;
while(b>=c)
{
ww=b/c;
b=b%c+ww;
w= w+ww;
}
cout << w<<endl;
}
return 0;
}
```
---
# 後續學習
- 學習資源
- https://drive.google.com/file/d/1B844ijhuV3dbOFNoNYviGh1acvNcoNKM/view?usp=sharing
- https://jmj.cmgsh.tp.edu.tw/files/AP325_v1.3.pdf
- 題單
- https://hackmd.io/@RwgiwD_zQHaL9zi1EW6ewg/rybuzaCvA