版权声明:转载请注明出处https://blog.csdn.net/hhmy77 https://blog.csdn.net/hhmy77/article/details/88778597
猜年龄
枚举 答案 18岁
代码(皮一下)
#include<bits/stdc++.h>
using namespace std;
int main()
{
printf("%d %d %d",18,18*18*18,18*18*18*18);
}
马虎的算式 三部排序 振兴中华 带分数 剪格子
https://blog.csdn.net/hhmy77/article/details/88777814讲过了
幻方填空
枚举或者搜索
这道题代码不再这台电脑上 晚点回来补上。
最小公倍数
建议记住这个结论 m/b*n 因为会溢出 所以我们先乘
// 交换数值
void swap(int *a,int *b)
{
int temp;
temp=*a;
*a=*b;
*b=temp;
}
void myfunc(int a, int b)
{
int m,n,r;
if(a<b) swap(&a,&b);
m=a;n=b;r=a%b;
while(r!=0)
{
a=b;b=r;
r=a%b;
}
printf("%d\n",b); // 最大公约数
printf("%d\n", m/b*n); // 最小公倍数
}
核桃的数量
只有三个数 我们轮流求最小公倍数就行了
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
if(b==0)return a;
return gcd(b,a%b);
}
int main()
{
int a,b,c;
cin>>a>>b>>c;
//Á½¸öÊýµÄ×îС¹«±¶Êý£¿
int A[3]={a,b,c};
sort(A,A+3);
//Á½¸ö×î´ó¹«ÒòÊý
int d1=gcd(A[0],A[1]);
int d2=gcd(A[1],A[2]);
//Á½¸ö×î´ó¹«±¶Êý
int c1=A[0]/d1*A[1];
int c2=A[1]/d2*A[2];
//×îÖÕµÄ×î´ó¹«ÒòÊý
int c3=gcd(c1,c2);
//×îÖÕµÄ×î´ó¹«±¶Êý
cout<<c1/c3*c2;
}