*zero judge C++*
==
# a
## a001
```cpp=
//a001
#include<bits/stdc++.h>
using namespace std;
int main()
{
string a;
cin>>a;
cout<<"hello, ";
cout<<a;
}
```
## a002
```cpp=
//a002
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
cout<<a+b;
}
```
## a003
```cpp=
//a003
#include<bits/stdc++.h>
using namespace std;
int main()
{
int m,d,s;
cin>>m>>d;
s=(m*2+d)%3;
if(s==0)
{
cout<<"普通";
}
if(s==1)
{
cout<<"吉";
}
if(s==2)
{
cout<<"大吉";
}
}
```
## a004
```cpp=
//a004
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
int b=0;
while(cin>>a)
{
if(a%4==0&&a%100!=0)
{
cout<<"閏年"<<endl;
b=1;
}
if(a%400==0)
{
cout<<"閏年"<<endl;
b=1;
}
if(b==0)
{
cout<<"平年"<<endl;
}
b=0;
}
}
```
## a005
```cpp=
//a005
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
int c[4];
cin>>n;
for(int times=0;times<n;times++)
{
for(int b=0;b<4;b++)
{
cin>>c[b];
cout<<c[b]<<' ';
}
if(c[0]+c[2]==2*c[1])
{
cout<<c[3]+c[2]-c[1]<<endl;
}
else
{
cout<<c[3]*(c[2]/c[1])<<endl;
}
}
}
```
## a024
```cpp=
//a024
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
int store;
if(a>b)
{
store=a;
a=b;
b=store;
}
while(a!=0&&b!=0)
{
if(a!=0)
{
b=b%a;
}
if(b!=0)
{
a=a%b;
}
}
if(a==0)
{
cout<<b;
}
if(b==0)
{
cout<<a;
}
}
```
## a038
```cpp=
//a038
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int a;
cin>>a;
if(a==0)
{
cout<<0;
}
while(a>0)
{
if(a%10!=0)
{
break;
}
a/=10;
}
while(a>0)
{
cout<<a%10;
a/=10;
}
}
```
## a040
```cpp=
//a040
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int a,b;
cin>>a>>b;
int n=0;
int store;
int total=0;
int ifcout=0;
for(int num=a;num<b+1;num++)
{
store=num;
while(num>0)
{
num/=10;
n+=1;
}
num=store;
while(num>0)
{
total+=pow(num%10,n);
num/=10;
}
num=store;
if(total==store)
{
cout<<total<<' ';
ifcout=1;
}
total=0;
n=0;
}
if(ifcout==0)
{
cout<<"none";
}
}
```
## a042
```cpp=
//a042
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
while(cin>>a)
{
a=pow(a,2)+2-a;
cout<<a<<endl;
}
}
```
## a044
```cpp=
//a044
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
while(cin>>a)
{
a=(pow(a,3)+5*a+6)/6;
cout<<a<<endl;
}
}
```
## a244
```cpp=
//a244
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
long long int a,b,c;
cin>>n;
for(int r=0;r<n;r++)
{
cin>>a>>b>>c;
if(a==1)
{
cout<<b+c<<endl;
}
if(a==2)
{
cout<<b-c<<endl;
}
if(a==3)
{
cout<<b*c<<endl;
}
if(a==4)
{
cout<<b/c<<endl;
}
}
}
```
## a799
```cpp=
//a799
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
cin>>a;
if(a<0)
{
a=(-1)*a;
}
cout<<a;
}
```
# b
## b294
```cpp=
//b294
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
cin>>a;
int t=0;
int amo;
for(int b=1;b<a+1;b++)
{
cin>>amo;
t+=amo*b;
}
cout<<t;
}
```
## b330
```cpp=
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b;
int coun=0;
cin>>a>>b;
for(int c=1;c<a+1;c++)
{
int d=c;
while(d>0)
{
if(d%10==b)
{
coun+=1;
}
d/=10;
}
}
cout<<coun;
}
```
## b964
```cpp=
//b964
#include<bits/stdc++.h>
using namespace std;
int main(){
int a;
int n;
int li[20];
cin>>a;
for (int b=0;b<a;b++){
cin>>li[b]; //讀數值進來
}
sort(li,li+a);
for (int bt=0;bt<a;bt++){
if (bt==a-1){
cout<<li[bt]<<endl;
}
else{
cout<<li[bt]; //排列並印出來
cout<<' ';
}
}
if (li[0]>=60){ //如最小值大於六十
cout<<"best case"<<endl;
}
else{
for (int c=0;c<a;c++){
if (li[c]>=60){
cout<<li[c-1]<<endl;//找最接近六十的不及格
break;
}
}
if (li[a-1]<60){
cout<<li[a-1]<<endl;
}
}
if (li[a-1]<60){
cout<<"worst case"<<endl; //如最大值小於六十
}
else{
for(int v=0;v<a;v++){
if (li[v]>=60){ //找最斤六十的及格分
cout<<li[v];
break;
}
}
}
}
```
# c
## c290
```cpp=
//c290. APCS 2017-0304-1秘密差
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
int a,e=0,o=0,t=0;
cin>>a;
while(a>0){
t++;
if (t%2!=0){
o+=a%10;
a/=10;}
if (t%2==0){
e+=a%10;
a/=10;
}
}
int ans1=e-o;
int ans2=o-e;
if (e-o>=0){
cout<<ans1;
}
else{
cout<<ans2;
}
}
```
## c291
```cpp=
//c291
#include<bits/stdc++.h>
using namespace std;
int sta;
int a;
int pos;
int num[50000];
int rec[50002]={0};//初始化設為0
int cou=0;
int main(){
cin>>a;
for (int b=0;b<a;b++){
cin>>num[b];
}
for(int b=0;b<a;b++){
if(rec[b]==0){
sta=b;
rec[sta]=1;
pos=num[b];
while(sta!=pos){
rec[pos]=1;
pos=num[pos];
}
cou+=1;
}
}
cout<<cou;
}
```
## c294
```cpp=
//c294
#include<bits/stdc++.h>
using namespace std;
int main(){
int tri[3];
for (int a=0;a<3;a++){
cin>>tri[a];
}
sort(tri,tri+3);
for (int a=0;a<3;a++){
if (a==2){
cout<<tri[2]<<endl;
}
else{
cout<<tri[a];
cout<<' ';
}
}
if (tri[0]+tri[1]<=tri[2]){
cout<<"No";
}
else{
if (tri[0]*tri[0]+tri[1]*tri[1]==tri[2]*tri[2]){
cout<<"Right";
}
if (tri[0]*tri[0]+tri[1]*tri[1]>tri[2]*tri[2]){
cout<<"Acute";
}
if (tri[0]*tri[0]+tri[1]*tri[1]<tri[2]*tri[2]){
cout<<"Obtuse";
}
}
}
```
## c295
```cpp=
//c295
#include<bits/stdc++.h>
using namespace std;
int main(){
int line;
int man;
int rec[20][20];//排樹根人數的列表
int max1[20]={0};//美意行的最大值
int maxn=0;//最大值
int total=0;
int rec2[20]={0};//記錄每一航的最大值
int t=0;
int cn0=0;//計算不等於零的數量
cin>>line;
cin>>man;
for (int b=0;b<line;b++){
for (int c=0;c<man;c++){
cin>>rec[b][c];
}
}
for (int b=0;b<line;b++){
for (int c=0;c<man;c++){
if (rec[b][c]>maxn){
maxn=rec[b][c];
}
}
max1[b]=maxn;
maxn=-1;
}
for (int r=0;r<20;r++){
total+=max1[r];
}
cout<<total<<endl;
for (int a=0;a<line;a++){
if (total%max1[a]==0){
rec2[t]=max1[a];
t+=1;
}
}
if (t==0){
cout<<-1;
}
else{
for (int q=0;q<20;q++){
if (rec2[q]!=0){
cn0+=1;
}
}
for (int m=0;m<cn0;m++){
if (m==cn0-1){
cout<<rec2[cn0-1];
}
else{
cout<<rec2[m]<<' ';
}
}
}
}
```
## c636
```cpp=
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
while(cin>>a)
{
if(a<0)
{
a=-1*a;
a=a%12;
a=13-a;
}
if(a%12==1)
{
cout<<"鼠"<<endl;
}
if(a%12==2)
{
cout<<"牛"<<endl;
}
if(a%12==3)
{
cout<<"虎"<<endl;
}
if(a%12==4)
{
cout<<"兔"<<endl;
}
if(a%12==5)
{
cout<<"龍"<<endl;
}
if(a%12==6)
{
cout<<"蛇"<<endl;
}
if(a%12==7)
{
cout<<"馬"<<endl;
}
if(a%12==8)
{
cout<<"羊"<<endl;
}
if(a%12==9)
{
cout<<"猴"<<endl;
}
if(a%12==10)
{
cout<<"雞"<<endl;
}
if(a%12==11)
{
cout<<"狗"<<endl;
}
if(a%12==0)
{
cout<<"豬"<<endl;
}
}
}
```
## c382
```cpp=
//c382
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b;
char c;
cin>>a>>c>>b;
if(c=='+')
{
cout<<a+b;
}
if(c=='-')
{
cout<<a-b;
}
if(c=='*')
{
cout<<a*b;
}
if(c=='/')
{
cout<<a/b;
}
}
```
## c418
```cpp=
//c418
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
cin>>a;
for(int b=1;b<a+1;b++)
{
cout<<string(b,'*')<<endl;
}
}
```
## c419
```cpp=
//c419
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
cin>>a;
for(int b=1;b<a+1;b++)
{
cout<<string(a-b,'_');
cout<<string(b,'*')<<endl;
}
}
```
## c420
```cpp=
//c420
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
cin>>a;
for(int b=1;b<a+1;b++)
{
cout<<string(a-b,'_');
cout<<string(2*(b-1)+1,'*');
cout<<string(a-b,'_')<<endl;
}
}
```
## c717
```cpp=
#include<bits/stdc++.h>
using namespace std;
int main()
{
string a;
getline(cin,a);
cout<<a<<' '<<a;
}
```
# d
## d064
```cpp=
//d064
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
cin>>a;
if(a%2==0)
{
cout<<"Even";
}
else
{
cout<<"Odd";
}
}
```
## d073
```cpp=
//d073
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
cin>>a;
if(a%3==0)
{
cout<<a/3;
}
else
{
cout<<a/3+1;
}
}
```
## d074
```cpp=
//d074
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
cin>>a;
int pe;
int ma=0;
while(cin>>pe)
{
if(pe>ma)
{
ma=pe;
}
}
cout<<ma;
}
```
## d827
```cpp=
//d827
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
cin>>a;
int con=0;
while(a>=12)
{
a-=12;
con+=1;
}
cout<<con*50+a*5;
}
```
# e
## e621
```cpp=
//e621
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
int b;
int c;
int d;
int lis[500]={0};
int con=0;
int lis2[500]={0};
int con2=0;
cin>>a;
for (int m=0;m<a;m++)
{
con=0;
con2=0;
cin>>b;
cin>>c;
cin>>d;
for (int t=b+1;t<c;t++)
{
lis[con]=t;
con++;
}
for (int y=0;y<con;y++)
{
if (lis[y]!=0&&lis[y]%d!=0)
{
lis2[con2]=lis[y];
con2++;
}
}
if (con2==0)
{
cout<<"No free parking spaces."<<endl;
}
else
{
for (int q=0;q<con2-1;q++)
{
cout<<lis2[q]<<' ';
}
cout<<lis2[con2-1]<<endl;
}
}
}
```
## e621
```cpp=
//e621
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
int st,ed,no;
int tel=0;
cin>>a;
for(int b=0;b<a;b++)
{
cin>>st>>ed>>no;
for(int q=st+1;q<ed;q++)
{
if(q%no!=0)
{
cout<<q<<' ';
tel=1;
}
}
if(tel==0)
{
cout<<"No free parking spaces.";
}
cout<<endl;
tel=0;
}
}
```
## e622
```cpp=
//e622
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
int sa;
int cp;
int iv;
int co=0;
int poke[50]={0};
int leveltimes;
int max1=0;
int comax=1;
cin>>n;
cin>>sa;
leveltimes=sa/1000;
for (int a=0;a<n;a++)
{
cin>>cp;
cin>>iv;
if (iv>=0&&iv<=29)
{
cp+=leveltimes*10;
poke[co]=cp;
}
if (iv>=30&&iv<=39)
{
cp+=leveltimes*50;
poke[co]=cp;
}
if (iv>=40&&iv<=45)
{
cp+=leveltimes*100;
poke[co]=cp;
}
co+=1;
}
for (int h=0;h<n;h++)
{
if (poke[h]>max1)
{
max1=poke[h];
comax=h+1;
}
}
cout<<comax<<' '<<max1;
}
```
## e623
```cpp=
//e623
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
cin>>a;
int con=0;
int tol=0;
int mh=0;
while(a>tol)
{
con+=1;
tol+=4*con;
}
tol-=4*con;
if(a-tol<=con)
{
cout<<"Pen";
}
if(a-tol>con&&a-tol<=2*con)
{
cout<<"Pineapple";
}
if(a-tol>2*con&&a-tol<=3*con)
{
cout<<"Apple";
}
if(a-tol>3*con&&a-tol<=4*con)
{
cout<<"Pineapple pen";
}
}
```
## e807
```cpp=
//e807
#include<bits/stdc++.h>
using namespace std;
int main()
{
float a[4];
float b[4];
float c[4];
float d[4];
float e[4];
float f[4];
float g[4];
int ma=0;
int mb=0;
int mc=0;
int md=0;
int me=0;
int mf=0;
int mg=0;
int week[7];
int mor=0;
int aft=0;
int nig=0;
int ear=0;
int duration[4];
for(int na=0;na<4;na++)
{
cin>>a[na];
ma+=a[na];
}
for(int nb=0;nb<4;nb++)
{
cin>>b[nb];
mb+=b[nb];
}
for(int nc=0;nc<4;nc++)
{
cin>>c[nc];
mc+=c[nc];
}
for(int nd=0;nd<4;nd++)
{
cin>>d[nd];
md+=d[nd];
}
for(int ne=0;ne<4;ne++)
{
cin>>e[ne];
me+=e[ne];
}
for(int nf=0;nf<4;nf++)
{
cin>>f[nf];
mf+=f[nf];
}
for(int ng=0;ng<4;ng++)
{
cin>>g[ng];
mg+=g[ng];
}
week[0]=ma;
week[1]=mb;
week[2]=mc;
week[3]=md;
week[4]=me;
week[5]=mf;
week[6]=mg;
int wemax=ma;
int wenum=0;
for(int num=0;num<7;num++)
{
if(week[num]>wemax)
{
wemax=week[num];
wenum=num;
}
}
wenum+=1;
cout<<wenum;
cout<<endl;
mor=a[0]+b[0]+c[0]+d[0]+e[0]+f[0]+g[0];
aft=a[1]+b[1]+c[1]+d[1]+e[1]+f[1]+g[1];
nig=a[2]+b[2]+c[2]+d[2]+e[2]+f[2]+g[2];
ear=a[3]+b[3]+c[3]+d[3]+e[3]+f[3]+g[3];
if(mor>aft&&mor>nig&&mor>ear)
{
cout<<"morning";
}
if(aft>mor&&aft>nig&&aft>ear)
{
cout<<"afternoon";
}
if(nig>mor&&nig>aft&&nig>ear)
{
cout<<"night";
}
if(ear>mor&&ear>aft&&ear>nig)
{
cout<<"early morning";
}
}
```
## e948
```cpp=
//e948
#include<bits/stdc++.h>
using namespace std;
int main()
{
int num;
int gender;
int high;
int weight;
int age;
float bmr;
cin>>num;
for(int a=0;a<num;a++)
{
cin>>gender;
cin>>age;
cin>>high;
cin>>weight;
if(gender==0)
{
bmr=9.6*weight+1.8*high-4.7*age+655;
printf("%.2f",bmr);
cout<<endl;
}
if(gender==1)
{
bmr=(13.7*weight)+(5*high)-(6.8*age)+66;
printf("%.2f",bmr);
cout<<endl;
}
}
}
```
## e968
```cpp=
//e968
#include<bits/stdc++.h>
using namespace std;
int main()
{
int num;
cin>>num;
int a[3];
int x=2;
int con=0;
cin>>a[0];
cin>>a[1];
cin>>a[2];
int sto=num;
sort(a,a+3);
while(num>0)
{
if(num!=a[x])
{
cout<<"No. "<<num;
con+=1;
if(con!=sto-3)
{
cout<<endl;
}
num-=1;
}
if(num==a[x])
{
num-=1;
x-=1;
if(x==-1)
{
x=2;
}
}
}
}
```
## e969
```cpp=
//e969
#include<bits/stdc++.h>
using namespace std;
int main()
{
int money,minu,k;
cin>>money>>minu>>k;
int totim=(-1)*minu;
int whether=0;
while(money>0)
{
if(k==1)
{
if(money>55)
{
money-=55;
totim+=minu;
whether=1;
cout<<totim<<": "<<"Wayne drinks a Corn soup, and now he has "<<money;
k=0;
if(money==1)
{
cout<<" dollar."<<endl;
}
else
{
cout<<" dollars."<<endl;
}
continue;
}
if(money==55)
{
money-=55;
totim+=minu;
whether=1;
cout<<totim<<": "<<"Wayne drinks a Corn soup, and now he doesn't have money.";
}
if(money<55)
{
break;
}
k=0;
}
if(k==0)
{
if(money>32)
{
money-=32;
totim+=minu;
whether=1;
cout<<totim<<": "<<"Wayne eats an Apple pie, and now he has "<<money;
if(money==1)
{
cout<<" dollar."<<endl;
}
else
{
cout<<" dollars."<<endl;
}
k=1;
continue;
}
if(money==32)
{
money-=32;
totim+=minu;
whether=1;
cout<<totim<<": "<<"Wayne eats an Apple pie, and now he doesn't have money.";
}
if(money<32)
{
break;
}
}
}
if(whether==0)
{
cout<<"Wayne can't eat and drink.";
}
}
```
# f
## f043
```cpp=
//f043
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
int b;
int ans;
int store;
cin>>a;
cin>>b;
if (a==b)
{
b-=3;
}
ans=a-b;
if (ans<b)
{
store=ans;
ans=b;
b=store;
}
cout<<b<<'+'<<ans<<'='<<a;
}
```
## f044
```cpp=
//f044
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
int b;
cin>>a;
cin>>b;
int tol=1;
int cou=0;
if (a!=1)
{
b/=a;
a=1;
}
while(tol!=(a+b))
{
if (tol!=(a+b))
{
tol*=2;
cou+=1;
}
}
cout<<cou;
}
```
## f044
```cpp=
//f044
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b;
int k=1;
int con=0;
cin>>a>>b;
if(a!=1)
{
b/=a;
a=1;
}
while(k!=a+b)
{
k*=2;
con+=1;
}
cout<<con;
}
```
## f045
```cpp=
//f045
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
cin>>a;
int sa;
int sec=-1;
int big=-1;
int sto;
int tol=0;
int sas;
sa=a;
for (int s=0;s<9;s++)
{
sto=a%10;
a/=10;
if (sto>big)
{
sec=big;
big=sto;
continue;
}
if (sto>sec)
{
sec=sto;
}
}
for (int r=0;r<9;r++)
{
sas=sa%10;
sa/=10;
if (r==2)
{
tol+=sas*100;
}
if (r==1)
{
tol+=sas*10;
}
if (r==0)
{
tol+=sas*1;
}
}
if (big*big+sec*sec==tol)
{
cout<<"Good Morning!";
}
else{
cout<<"SPY!";
}
}
```
## f071
```cpp=
//f071
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a[3];
int b[5];
int c[5];
int t=0;
int ifc3=0;
for(int d=0;d<3;d++)
{
cin>>a[d];
}
for(int e=0;e<5;e++)
{
cin>>b[e];
}
for(int f=0;f<5;f++)
{
cin>>c[f];
}
for(int h=0;h<5;h++)
{
if(a[0]==b[h])
{
t+=c[h];
}
if(a[1]==b[h])
{
t+=c[h];
}
if(a[2]==b[h])
{
t-=c[h];
ifc3=1;
}
}
if(ifc3==0)
{
t*=2;
}
if (t<=0)
{
cout<<0;
}
else
{
cout<<t;
}
}
```
## f373
```cpp=
//f373
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int tan,chi,tan1,chi1;
tan=n/2000;
chi=n/1000;
tan1=n-tan*200;
chi1=n-chi*100;
if (tan1<=chi1)
{
cout<<tan1<<' '<<0;
}
else{
cout<<chi1<<' '<<1;
}
}
```
## f373
```cpp=
//f373
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
cin>>a;
int chi=a-(a/1000)*100;
int tan=a-(a/2000)*200;
if(tan<=chi)
{
cout<<tan<<' '<<0;
}
else
{
cout<<chi<<' '<<1;
}
```
## f374
```cpp=
//f374
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
int p;
int matea=0;
int manum=0;
int tol=0;
int cou=0;
int team=0;
cin>>n;
cin>>p;
while(p>=1)
{
if (cou!=n)
{
tol+=p%10;
p/=10;
cou+=1;
}
if (cou==n)
{
team+=1;
cou=0;
if (manum<=tol)
{
manum=tol;
matea=team;
}
tol=0;
}
}
if (manum<=tol)
{
matea=team+1;
manum=tol;
}
cout<<matea<<' '<<manum;
}
```
## f375
```cpp=
//f375
#include<bits/stdc++.h>
using namespace std;
int main()
{
int st,pu,pa;
cin>>st>>pu>>pa;
int day=1;
while(true)
{
if(day%11==0)
{
pa-=1;
if(pa==0)
{
cout<<"unsalable";
break;
}
}
if(st>=pu)
{
cout<<day;
break;
}
if(st<pu)
{
if(day%9==0||day%10==0)
{
int nothing;
}
else
{
if(day%3!=0)
{
st+=st/10;
}
if(day%3==0)
{
st+=st/3;
}
}
}
day+=1;
}
}
```
## f424
```cpp=
//f424
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
cin>>a;
int a1=1;
int a2=3;
int con=2;
while(con<a)
{
a1=a1+a2;
a2=a2+a1;
con+=2;
}
if(a==1)
{
cout<<1;
}
if (a==2)
{
cout<<3;
}
if(a%2==0)
{
cout<<a2;
}
if(a%2!=0)
{
cout<<a1;
}
}
```
## f441
```cpp=
//f441
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
int ans[20];
for(int qw=0;qw<a;qw++)
{
cin>>ans[qw];
}
int num;
cin>>num;
int stuans;
int al=0;
for(int t=0;t<num;t++)
{
for(int y=0;y<a;y++)
{
cin>>stuans;
if(stuans==ans[y])
{
al+=b;
}
}
cout<<al<<endl;
al=0;
}
}
```
## f442
```cpp=
//f442
#include<bits/stdc++.h>
using namespace std;
int main()
{
int chickennum;
cin>>chickennum;
int ans[2000];
for(int b=0;b<chickennum;b++)
{
cin>>ans[b];
}
int eagle,round;
cin>>eagle>>round;
int listchicken[200];
for(int a=0;a<round;a++)
{
cin>>listchicken[a];
}
int store;
for(int c=0;c<round;c++)
{
for(int d=0;d<chickennum;d++)
{
if(listchicken[c]==ans[d])
{
store=eagle;
eagle=ans[d];
ans[d]=store;
}
}
}
for(int d=0;d<chickennum;d++)
{
cout<<ans[d]<<' ';
}
}
```
## f579
```cpp=
//f579
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
int people;
cin>>people;
int anum=0,bnum=0;
int total=0;
int store=1000;
for(int c=0;c<people;c++)
{
while(store!=0)
{
cin>>store;
if(store==a)
{
anum+=1;
}
if(store==(-1)*a)
{
anum-=1;
}
if(store==b)
{
bnum+=1;
}
if(store==(-1)*b)
{
bnum-=1;
}
}
if(bnum>0 && anum>0)
{
total+=1;
}
anum=0;
bnum=0;
store=1000;
}
cout<<total;
}
```
## f605
```cpp=
//f605
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
int d;
int rec[3]={0};
int tol=0;
int cou=0;
cin>>n;
cin>>d;
for (int a=0;a<n;a++){
for (int b=0;b<3;b++){
cin>>rec[b];
}
sort(rec,rec+3);
if (rec[2]-rec[0]>=d){
cou+=1;
tol+=(rec[0]+rec[1]+rec[2])/3;
}
}
cout<<cou<<' '<<tol;
}
```
## f706
```cpp=
//f706
#include<bits/stdc++.h>
using namespace std;
int main()
{
int ho;
int mi;
int se;
int zo;
cin>>ho;
cin>>mi;
cin>>se;
cin>>zo;
mi+=zo*30;
ho+=zo;
while(mi<0||mi>59)
{
if (mi<0)
{
ho-=1;
mi+=60;
}
if(mi>60)
{
ho+=1;
mi-=60;
}
}
while(ho<0||ho>35)
{
if (ho<0)
{
ho+=36;
}
if (ho>35)
{
ho-=36;
}
}
cout<<ho<<':';
if (mi<10)
{
cout<<0<<mi;
}
else
{
cout<<mi;
}
cout<<':';
if(se<10)
{
cout<<0<<se;
}
else
{
cout<<se;
}
}
```
## f707
```cpp=
//f707
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
cin>>a;
int maxnum;
maxnum=a;
while(cin>>a&&a!=0)
{
if(a%7==0&&maxnum%7==0&&a%70>maxnum%70)
{
maxnum=a;
}
if(a%7==0&&maxnum%7!=0)
{
maxnum=a;
}
if(a%7!=0&&maxnum%7!=0&&a%77<maxnum%77)
{
maxnum=a;
}
}
cout<<maxnum;
}
```
## f708
```cpp=
//f708
#include<bits/stdc++.h>
using namespace std;
int main()
{
int grass;
int ant;
int grasshi;
int anthi;
int grasstol=0;
int anttol=0;
cin>>ant;
cin>>grass;
for (int a=0;a<ant;a++)
{
cin>>anthi;
anttol+=anthi;
}
for (int b=0;b<grass;b++)
{
cin>>grasshi;
grasstol+=grasshi;
}
if (anttol>grasstol&&ant>grass)
{
cout<<"Yes";
}
else
{
cout<<"No";
}
}
```
## f818
```cpp=
//f818
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
cin>>a;
long long int mim=10000000,hi=0,wei=0;
int high[2005];
int weight[2005];
for(int b=0;b<a;b++)
{
cin>>high[b];
}
for(int c=0;c<a;c++)
{
cin>>weight[c];
}
for(int d=0;d<a;d++)
{
if(high[d]*weight[d]<mim)
{
mim=high[d]*weight[d];
hi=high[d];
wei=weight[d];
}
}
cout<<hi<<' '<<wei;
}
```
# g
## g496
```cpp=
//g496
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
int b;
cin>>a;
cin>>b;
if(b%a==0)
{
cout<<b/a;
}
if(b%a!=0)
{
cout<<b/a+1;
}
}
```
## g497
```cpp=
//g497
#include<bits/stdc++.h>
using namespace std;
int main()
{
int tol=0;
int floor1;
int floor2;
int time;
cin>>time;
cin>>floor1;
tol+=(floor1-1)*3;
floor2=floor1;
for (int u=1;u<time;u++)
{
cin>>floor1;
if (floor1-floor2<0)
{
tol+=(floor2-floor1)*2;
}
if (floor1-floor2>0)
{
tol+=(floor1-floor2)*3;
}
floor2=floor1;
}
cout<<tol;
}
```
## g498
```cpp=
//g948
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
int b=0;
int tol=0;
cin>>a;
cin>>b;
cin>>tol;
int anum;
int bnum;
int con=0;
int tell=0;
if (tol%a==0)
{
tell=1;
}
else
{
anum=tol/a+1;
}
if (tol%b==0)
{
tell=1;
}
else
{
bnum=tol/b+1;
}
while(anum>0&&tell==0)
{
while(con<bnum)
{
if(a*anum+b*con==tol)
{
tell=1;
break;
}
else
{
con+=1;
}
}
con=0;
anum-=1;
}
if(tell==0)
{
cout<<"NO";
}
if(tell==1)
{
cout<<"YES";
}
}
```
## g595
```cpp=
//g595
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
cin>>a;
int fenceheight;
int fence[106]={101};
int needheight=0;
for(int c=0;c<a;c++)
{
cin>>fenceheight;
fence[c]=fenceheight;
}
for(int d=0;d<a;d++)
{
if(fence[d]==0&&d!=0&&d!=a)
{
if(fence[d+1]>=fence[d-1])
{
needheight+=fence[d-1];
}
else
{
needheight+=fence[d+1];
}
}
}
if(fence[0]==0)
{
needheight+=fence[1];
}
if(fence[a-1]==0)
{
needheight+=fence[a-2];
}
cout<<needheight;
}
```
## g797
```cpp=
//g797
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
int fir[155];
int las[155];
int fina[310];
int sign=0;
int firn=0;
int lasn=0;
int halfn=n/2;
for(int c=0;c<n;c++)
{
cin>>fina[c];
}
for(int y=0;y<m;y++)
{
for(int a=0;a< halfn;a++)
{
fir[a]=fina[a];
}
for(int b=0;b<halfn;b++)
{
las[b]=fina[b+halfn];
}
for(int y=0;y<m;y++)
{
for(int t=0;t<n;t++)
{
if(sign==1)
{
fina[t]=las[lasn];
lasn+=1;
sign=0;
}
else
{
fina[t]=fir[firn];
firn+=1;
sign=1;
}
}
firn=0;
lasn=0;
}
}
for(int num=0;num<n;num++)
{
cout<<fina[num]<<' ';
}
}
```
# h
## h026
```cpp=
#include<bits/stdc++.h>
using namespace std;
int main()
{
int F,N;
cin>>F>>N;
int sese[10]={0};
int ifrepeat=0;
int store=-1;
int ifgame=0;
for(int a=0;a<N;a++)
{
cin>>sese[a];
if(a!=0)
{
if(ifrepeat==1)
{
if(store==0)
{
F=5;
}
if(store==2)
{
F=0;
}
if(store==5)
{
F=2;
}
}
}
ifrepeat=0;
if(sese[a]==store)
{
ifrepeat=1;
}
store=sese[a];
cout<<F<<' ';
if(sese[a]==0&&F==2)
{
cout<<": ";
cout<<"Lost at round "<<a+1;
ifgame=1;
break;
}
if(sese[a]==2&&F==0)
{
cout<<": ";
cout<<"Won at round "<<a+1;
ifgame=1;
break;
}
if(sese[a]==2&&F==5)
{
cout<<": ";
cout<<"Lost at round "<<a+1;
ifgame=1;
break;
}
if(sese[a]==5&&F==2)
{
cout<<": ";
cout<<"Won at round "<<a+1;
ifgame=1;
break;
}
if(sese[a]==0&&F==5)
{
cout<<": ";
cout<<"Won at round "<<a+1;
ifgame=1;
break;
}
if(sese[a]==5&&F==0)
{
cout<<": ";
cout<<"Lost at round "<<a+1;
ifgame=1;
break;
}
}
if(ifgame==0)
{
cout<<": ";
cout<<"Drew at round "<<N;
}
}
```
## h081
```cpp=
//h081
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
int ifsell=0;
int profit=0;
int price;
int ifhas=1;
cin>>price;
int store;
for(int c=1;c<a;c++)
{
cin>>store;
if(store>=price+b&&ifhas==1)
{
profit+=store-price;
price=store;
ifhas=0;
}
if(store<=price-b&&ifhas==0)
{
price=store;
ifhas=1;
}
}
cout<<profit;
}
```
## h658
```cpp=
//h658
#include<bits/stdc++.h>
using namespace std;
int main()
{
int x1;
int y1;
int n;
int x2;
int y2;
cin>>x1;
cin>>y1;
cin>>n;
int maxn=1234567845;
int maxx2;
int maxy2;
for(int a=0;a<n;a++)
{
cin>>x2;
cin>>y2;
if((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)<maxn)
{
maxn=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
maxx2=x2;
maxy2=y2;
}
}
cout<<maxx2<<' '<<maxy2;
}
```
## h659
```cpp=
//h659
#include<bits/stdc++.h>
using namespace std;
int main()
{
int km,wait,on,down;
cin>>km>>wait>>on>>down;
int money=0;
if(km<=2)
{
money+=20;
}
if(km>2)
{
money+=20;
money+=(km-2)*5;
}
money+=(wait/2)*5;
if(on<=18&&down>=19)
{
money+=185;
}
if(on<=19&&down>=20)
{
money+=195;
}
if(on<=20&&down>=21)
{
money+=205;
}
if(on<=21&&down>=22)
{
money+=215;
}
if(on<=22&&down>=23)
{
money+=225;
}
cout<<money;
}
```
## h660
```cpp=
//h660
#include<bits/stdc++.h>
using namespace std;
int main()
{
int x,r,v;
cin>>x>>r>>v;
int n;
cin>>n;
int ball,speed;
for(int a=0;a<n;a++)
{
cin>>ball>>speed;
if(ball>=x-r&&x+r>=ball)
{
if(speed<=v)
{
x=ball;
}
else
{
if(ball-x>=0)
{
x-=15;
}
else
{
x+=15;
}
}
}
else
{
int nomove;
}
}
cout<<x;
}
```
# i
## i399
```cpp=
//i399
#include<bits/stdc++.h>
using namespace std;
int main(){
int yu[3];
for (int a=0;a<3;a++){
cin>>yu[a];
}
sort(yu,yu+3);
while (true){
if (yu[0]==yu[1]&&yu[1]==yu[2]){
cout<<3 ;
cout<<' ';
cout<<yu[0];
break;
}
if (yu[0]==yu[1]){
cout<<2 ;
cout<<' ';
cout<<yu[2];
cout<<' ';
cout<<yu[0];
break;
}
if (yu[2]==yu[1]){
cout<<2 ;
cout<<' ';
cout<<yu[2];
cout<<' ';
cout<<yu[0];
break;
}
if (yu[0]!=yu[1]!=yu[2]){
cout<<1 ;
cout<<' ';
cout<<yu[2];
cout<<' ';
cout<<yu[1];
cout<<' ';
cout<<yu[0];
break;
}
}
}
```
![螢幕擷取畫面 2023-12-20 161047](https://hackmd.io/_uploads/r10_bXxPa.png)
# j
## j708
```cpp=
//j708
#include<bits/stdc++.h>
using namespace std;
int main()
{
float a,b,c;
cin>>a>>b>>c;
float v,to;
v=a*b*c;
to=2*(a*b+b*c+a*c);
printf("%.1f",to);
cout<<' ';
printf("%.1f",v);
}
```
![螢幕擷取畫面 2023-12-20 161236](https://hackmd.io/_uploads/HJp2b7gP6.png)
## j709
```cpp=
//j709
#include<bits/stdc++.h>
using namespace std;
int main()
{
float a,b,c;
float area;
cin>>a>>b>>c;
area=((a+b)*c)*0.5;
printf("%.1f",area);
}
```
![螢幕擷取畫面 2023-12-20 161353](https://hackmd.io/_uploads/SkUZGQlD6.png)
## j710
```cpp=
//j710
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
cin>>a;
if(a>1)
{
cout<<70+30*(a-1);
}
else
{
cout<<70;
}
}
```
![螢幕擷取畫面 2023-12-20 161441](https://hackmd.io/_uploads/Skm4MQlwp.png)
## j711
```cpp=
//j711
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
cin>>a;
int t=0;
while(a>0)
{
t+=a%10;
a/=10;
}
cout<<t;
}
```
![螢幕擷取畫面 2023-12-20 161526](https://hackmd.io/_uploads/rJoIG7lDa.png)
## j712
```cpp=
//j712
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
int c50=0;
int c10=0;
int c5=0;
int c1=0;
cin>>a;
while(a>=50)
{
c50+=1;
a-=50;
}
while(a>=10)
{
c10+=1;
a-=10;
}
while(a>=5)
{
c5+=1;
a-=5;
}
while(a>=1)
{
c1+=1;
a-=1;
}
cout<<c50<<' '<<c10<<' '<<c5<<' '<<c1;
}
```
# k
![螢幕擷取畫面 2023-12-20 161827](https://hackmd.io/_uploads/S1DfXQeDT.png)
## k030
```cpp=
//k030
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
cin>>a;
if (a==1||a==2)
{
if(a==1)
{
cout<<'*';
}
if(a==2)
{
cout<<' '<<'*'<<endl;
cout<<string(2,'*');
}
}
else
{
cout<<string(a-1,' ')<<'*'<<endl;
cout<<string(a-2,' ')<<string(2,'*')<<endl;
for(int c=3;c<=a;c++)
{
if(c==a)
{
cout<<string(a,'*');
}
else
{
cout<<string(a-c,' ');
cout<<'*';
cout<<string(c-2,' ');
cout<<'*'<<endl;
}
}
}
}
```
![螢幕擷取畫面 2023-12-20 161907](https://hackmd.io/_uploads/BJeSmQlwT.png)
## k031
```cpp=
//k031
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
int con=0;
cin>>a;
for(int b=0;b<a;b++)
{
for (int q=a;q>b;q--)
{
cout<<' ';
}
con=0;
while(con<(2*b+1))
{
cout<<'*';
con+=1;
}
cout<<endl;
}
for(int y=0;y<a-1;y++)
{
for (int j=0;j<y+2;j++)
{
cout<<' ';
}
con=0;
while(con<(2*a-3-2*y))
{
cout<<'*';
con+=1;
}
cout<<endl;
}
}
```
![螢幕擷取畫面 2023-12-20 162011](https://hackmd.io/_uploads/BJhd7XeDT.png)
## k937
```cpp=
//k937
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t=0;
int a=0;
int b,stor;
cin>>b;
stor=b;
while(b>0)
{
t+=(b%10)*(b%10)*(b%10);
b/=10;
if(stor==t)
{
a=1;
}
}
cout<<a;
```
# l
## l960
```cpp=
#include<bits/stdc++.h>
using namespace std;
int main()
{
string a;
int tell=0;
getline(cin,a);
if(a=="Sunday")
{
cout<<0;
tell=1;
}
if(a=="Monday")
{
cout<<1;
tell=1;
}
if(a=="Tuesday")
{
cout<<2;
tell=1;
}
if(a=="Wednesday")
{
cout<<3;
tell=1;
}
if(a=="Thursday")
{
cout<<4;
tell=1;
}
if(a=="Friday")
{
cout<<5;
tell=1;
}
if(a=="Saturday")
{
cout<<6;
tell=1;
}
if(tell==0){
cout<<"error";
}
}
```