#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int f(int temp,int t)
{
if(temp<t)
{
f(t,temp);
}
else
return temp%t==0 ? t:f(t,temp%t);
}
int main()
{
int n;
while(cin>>n)
{
int temp=1;
int a;
while(cin>>a)
{
temp=temp/f(a,temp)*a;
if(cin.get()=='\n')
break;
}
cout<<temp<<endl;
}
}
HDU2029
在这里插入代码片
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main()
{
int n;
char s[65535];
cin>>n;
while(n--)
{
int flag=0;
cin>>s;
for(int i=0;i<strlen(s)/2&&!flag;i++)
{
if(s[i]==s[strlen(s)-i-1])
{
continue;
}
else
{
flag=1;
}
}
if(flag==0)
cout<<"yes"<<endl;
else
cout<<"no"<<endl;
}
}
注意一下字符数组的读入方法,
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main()
{
int n;
char s[65535];
cin>>n;
while(n--)
{
int flag=0;
cin>>s;
for(int i=0;i<strlen(s)/2&&!flag;i++)
{
if(s[i]==s[strlen(s)-i-1])
{
continue;
}
else
{
flag=1;
}
}
if(flag==0)
cout<<"yes"<<endl;
else
cout<<"no"<<endl;
}
}