1056题目:
http://ac.jobdu.com/problem.php?pid=1056
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#define ISYEAP(x) x%100!=0 && x%4==0 || x%400==0 ? 1:0
using namespace std;
int main(){
int a,b;
int t;
while(cin>>a>>b){
while(1){
t=a%b;
if(t==0){
t=b;
break;
}
a=b;
b=t;
}
cout<<t<<endl;
}
}
/**************************************************************
Problem: 1056
User: zhouyudut
Language: C++
Result: Accepted
Time:0 ms
Memory:1520 kb
****************************************************************/
1438题目:
http://ac.jobdu.com/problem.php?pid=1438
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#define ISYEAP(x) x%100!=0 && x%4==0 || x%400==0 ? 1:0
using namespace std;
int main(){
int a,b;
int t;
while(cin>>a>>b){
int tempa=a;
int tempb=b;
while(1){
t=a%b;
if(t==0){
t=b;
break;
}
a=b;
b=t;
}
cout<<(tempa*tempb)/t<<endl;
}
}
/**************************************************************
Problem: 1438
User: zhouyudut
Language: C++
Result: Accepted
Time:10 ms
Memory:1520 kb
****************************************************************/
1439题目:
http://ac.jobdu.com/problem.php?pid=1439
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#define ISYEAP(x) x%100!=0 && x%4==0 || x%400==0 ? 1:0
using namespace std;
unsigned long long int lcm(unsigned long long int a,unsigned long long int b){
if(b==0)
return a;
long long int t;
long long int tempa=a;
long long int tempb=b;
while(1){
t=tempa%tempb;
if(t==0)
{
t=tempb;
break;
}
tempa=tempb;
tempb=t;
}
return a*b/t;
}
int main(){
unsigned long long int a,b;
unsigned long long int num,count;
cin>>num;
for(unsigned long long int i=0;i<num;i++){
cin>>count;
a=1;
for(unsigned long long int j=0;j<count;j++){
cin>>b;
a=lcm(a,b);
}
cout<<a<<endl;
}
}
/**************************************************************
Problem: 1439
User: zhouyudut
Language: C++
Result: Accepted
Time:10 ms
Memory:1520 kb
****************************************************************/
对于这题,注意数的范围,这玩意很坑的