HDU ACM 1160 为什么WA
#include<iostream>#include<stdio.h>#include<algorithm>#include<stdlib.h>usingnamespac...
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
using namespace std;
struct Node{
int a;
int b;
int father;
int biaozhi;
}shu[1001];
int f[1001];
bool Cmp(const Node &b,const Node &c)
{
return (b.a<c.a||b.a==c.a&&b.b>c.b);
}
int maxx(int a,int b)
{
if (a>b)
return a;
else return b;
}
int x,y;
void print(int x)
{
if (shu[x].father!=0)
{
print(shu[x].father);
cout<<shu[x].biaozhi<<endl;
}
else
{
cout<<shu[x].biaozhi<<endl;
return ;
}
}
int main()
{
int n=0,i,j,k=9,l,max;
while ((scanf("%d %d",&x,&y))!=EOF)
{
n++;
shu[n].a=x;
shu[n].b=y;
f[n]=1;
shu[n].biaozhi=n;
shu[n].father=0;
}
sort(shu+1,shu+n+1,Cmp);
for (i=1;i<=n;i++)
for (j=1;j<=i-1;j++)
if ((shu[j].a<shu[i].a)&&(shu[j].b>shu[i].b))
{
f[i]=maxx(f[i],f[j]+1);
shu[i].father=j;
}
max=0;
for (i=1;i<=n;i++)
if (max<f[i])
{
max=f[i];
j=i;
}
cout<<max<<endl;
print(j);
}
其实这题我已经搞定了 谁第一个随便发个这题的题解 我就给满意答案^_^ 展开
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
using namespace std;
struct Node{
int a;
int b;
int father;
int biaozhi;
}shu[1001];
int f[1001];
bool Cmp(const Node &b,const Node &c)
{
return (b.a<c.a||b.a==c.a&&b.b>c.b);
}
int maxx(int a,int b)
{
if (a>b)
return a;
else return b;
}
int x,y;
void print(int x)
{
if (shu[x].father!=0)
{
print(shu[x].father);
cout<<shu[x].biaozhi<<endl;
}
else
{
cout<<shu[x].biaozhi<<endl;
return ;
}
}
int main()
{
int n=0,i,j,k=9,l,max;
while ((scanf("%d %d",&x,&y))!=EOF)
{
n++;
shu[n].a=x;
shu[n].b=y;
f[n]=1;
shu[n].biaozhi=n;
shu[n].father=0;
}
sort(shu+1,shu+n+1,Cmp);
for (i=1;i<=n;i++)
for (j=1;j<=i-1;j++)
if ((shu[j].a<shu[i].a)&&(shu[j].b>shu[i].b))
{
f[i]=maxx(f[i],f[j]+1);
shu[i].father=j;
}
max=0;
for (i=1;i<=n;i++)
if (max<f[i])
{
max=f[i];
j=i;
}
cout<<max<<endl;
print(j);
}
其实这题我已经搞定了 谁第一个随便发个这题的题解 我就给满意答案^_^ 展开
2个回答
展开全部
是大数的关系把
你参考下我的AC代码;
#include <stdio.h>
#include <math.h>
int GetLmdByLog(int N)
{
int i,LMD;
double x=N*log10(N);
LMD=pow(10,x-floor(x));
return LMD;
}
int main()
{
int N,LMD,x;
scanf("%d",&x);
while(x--)
{
scanf("%d",&N);
LMD=GetLmdByLog(N);
printf("%d\n",LMD);
}
}
你参考下我的AC代码;
#include <stdio.h>
#include <math.h>
int GetLmdByLog(int N)
{
int i,LMD;
double x=N*log10(N);
LMD=pow(10,x-floor(x));
return LMD;
}
int main()
{
int N,LMD,x;
scanf("%d",&x);
while(x--)
{
scanf("%d",&N);
LMD=GetLmdByLog(N);
printf("%d\n",LMD);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询