delete pics to save space
This commit is contained in:
19
history_source/ccf 基础篇/U8/8.6.1.cpp
Normal file
19
history_source/ccf 基础篇/U8/8.6.1.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int zd(int a,int b)
|
||||
{
|
||||
return (b==0)?a:zd(b,a%b);
|
||||
}
|
||||
int zx(int a,int b)
|
||||
{
|
||||
return a*b/zd(a,b);
|
||||
}
|
||||
int main()
|
||||
{
|
||||
int n,m;
|
||||
while(true)
|
||||
{
|
||||
cin>>n>>m;
|
||||
cout<<zx(n,m)<<endl;
|
||||
}
|
||||
}
|
41
history_source/ccf 基础篇/U8/8.6.2.cpp
Normal file
41
history_source/ccf 基础篇/U8/8.6.2.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
#include<cstdio>
|
||||
using namespace std;
|
||||
unsigned long long gcd(unsigned long long m,unsigned long long n)
|
||||
{
|
||||
int x=1;
|
||||
unsigned long long t;
|
||||
begin:if(m==n) return x*m;
|
||||
if(m<n)
|
||||
{
|
||||
t=m,m=n,n=t;
|
||||
goto begin;
|
||||
}
|
||||
if(m&1)
|
||||
{
|
||||
if(n&1)
|
||||
{
|
||||
t=n;
|
||||
n=m-n;
|
||||
m=t;
|
||||
goto begin;
|
||||
}
|
||||
n=n>>1;
|
||||
goto begin;
|
||||
}
|
||||
if(n&1)
|
||||
{
|
||||
m=m>>1;
|
||||
goto begin;
|
||||
}
|
||||
x=x*2;
|
||||
m=m>>1;
|
||||
n=n>>1;
|
||||
goto begin;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
unsigned long long n,m;
|
||||
scanf("%lld%lld",&n,&m);
|
||||
printf("%lld\n",gcd(n,m));
|
||||
return 0;
|
||||
}
|
41
history_source/ccf 基础篇/U8/8.6.3.cpp
Normal file
41
history_source/ccf 基础篇/U8/8.6.3.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
#include<cstdio>
|
||||
using namespace std;
|
||||
unsigned long long gcd(unsigned long long m,unsigned long long n)
|
||||
{
|
||||
int x=1;
|
||||
unsigned long long t;
|
||||
begin:if(m==n) return x*m;
|
||||
if(m<n)
|
||||
{
|
||||
t=m,m=n,n=t;
|
||||
goto begin;
|
||||
}
|
||||
if(m&1)
|
||||
{
|
||||
if(n&1)
|
||||
{
|
||||
t=n;
|
||||
n=m-n;
|
||||
m=t;
|
||||
goto begin;
|
||||
}
|
||||
n=n>>1;
|
||||
goto begin;
|
||||
}
|
||||
if(n&1)
|
||||
{
|
||||
m=m>>1;
|
||||
goto begin;
|
||||
}
|
||||
x=x*2;
|
||||
m=m>>1;
|
||||
n=n>>1;
|
||||
goto begin;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
unsigned long long n,m;
|
||||
scanf("%lld%lld",&n,&m);
|
||||
printf("%lld\n",gcd(n,m));
|
||||
return 0;
|
||||
}
|
33
history_source/ccf 基础篇/U8/8.6.4.cpp
Normal file
33
history_source/ccf 基础篇/U8/8.6.4.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#include<cstdio>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
bool x;
|
||||
int t;
|
||||
int m;
|
||||
scanf("%d",&t);
|
||||
int sr[t];
|
||||
for(int i=0;i<t;i++) scanf("%d",sr+i);
|
||||
for(int i=0;i<t;i++)
|
||||
{
|
||||
x=0;
|
||||
for(int j=2;j<=sr[i];j++)
|
||||
{
|
||||
if(sr[i]%j==0)
|
||||
{
|
||||
if(x) printf("*");
|
||||
m=0;
|
||||
while(sr[i]%j==0)
|
||||
{
|
||||
m++;
|
||||
sr[i]/=j;
|
||||
}
|
||||
printf("%d",j);
|
||||
if(m>1) printf("^%d",m);
|
||||
x=1;
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user