2020/11/04 09:18

# Problem_A_判断公倍数

Description

——————————————
Input

——————————————
Output

——————————————
Sample Input
6
5
——————————————
Sample Output
Yes
No

#include<cstdio>
using namespace std;
int main()
{

int n;
while(~scanf("%d",&n))
{

if(n%3==0 && n%2==0)
printf("Yes\n");
else
printf("No\n");
}
return 0;
}


# Problem_B_包含3的整数个数

Description

——————————————
Input

——————————————
Output

——————————————
Sample Input
2 15
10 24
——————————————
Sample Output
16
36

#include<cstdio>
using namespace std;

bool check(int x)
{

int temp;
while(x)
{

temp=x%10;
if(temp==3)	return true;
x/=10;
}
return false;
}

int main()
{

int l,r;
while(~scanf("%d%d",&l,&r))
{

int ans=0;
for(int i=l;i<=r;i++)
if(check(i))
ans+=i;
printf("%d\n",ans);
}
}


# Problem_C_公约数和公倍数

Description

——————————————
Input

——————————————
Output

——————————————
Sample Input
2 3
21 9
——————————————
Sample Output
1
6
3
63

#include<cstdio>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
using namespace std;

int gcd(int a,int b)
{

if(a%b==0)
return b;
return gcd(b,a%b);
}

int main()
{

int a,b;
while(~scanf("%d%d",&a,&b))
{

int Gcd=gcd(max(a,b),min(a,b));
printf("%d\n%d\n",Gcd,a*b/Gcd);
}
}


# Problem_D_判断是一年中的哪一天

Description

——————————————
Input

——————————————
Output

——————————————
Sample Input
2010 1 6
2012 3 2
——————————————
Sample Output
6
62

#include<cstdio>
using namespace std;
int mon[15]={

0,31,0,31,30,31,30,31,31,30,31,30,31};

bool isr(int Y)
{

if((Y%4==0 && Y%100!=0) || Y%400==0)
return true;
else	return false;
}

int main()
{

int y,m,d;
while(~scanf("%d%d%d",&y,&m,&d))
{

int cnt=0;

if(isr(y))	mon[2]=29;
else		mon[2]=28;

for(int i=1;i<m;i++)
cnt+=mon[i];
cnt+=d;
printf("%d\n",cnt);
}
return 0;
}


# Problem_E_三角形面积计算

Description

——————————————
Input

——————————————
Output

——————————————
Sample Input
3 4 5
2 6 6
3.5 7.83 6.178
——————————————
Sample Output
6.00
5.92
10.46

#include<cmath>
#include<cstdio>
using namespace std;

int main()
{

double a,b,c,p;
while(~scanf("%lf%lf%lf",&a,&b,&c))
{

p=(a+b+c)/2;
printf("%.2f\n",sqrt(p*(p-a)*(p-b)*(p-c)));
}
return 0;
}


0
0 收藏

0 评论
0 收藏
0