Problem 1001Time Limit:1 Sec Memory Limit:128 MBSubmit:33 So

Problem 1001
Time Limit:1 Sec Memory Limit:128 MB
Submit:33 Solved:29
[Submit][Status][Web Board]
Description
As we known,data stored in the computers is in binary form.The problem we discuss now is about the positive integers and its binary form.
Given a positive integer I,you task is to find out an integer J,which is the minimum integer greater than I,and the number of '1's in whose binary form is the same as that in the binary form of I.
For example,if "78" is given,we can write out its binary form,"1001110".This binary form has 4 '1's.The minimum integer,which is greater than "1001110" and also contains 4 '1's,is "1010011",i.e."83",so you should output "83".
Input
One integer per line,which is I (1 =i;j--)
x05a[j]=0;
x05s=0;q=0;
x05for(i=0;i=i;j--)
x05s+=a[j]*pow(2,q++);
x05printf("%ldn",s);
}
x05}
}
想知道为什么WA
bingruyan 1年前 已收到1个回答 举报

shaoji1919 春芽

共回答了16个问题采纳率:93.8% 举报

;
using namespace std;
#define MIN(a,b) ((a)<(b))?(a):(b)
#define MAX(a,b) ((a)>(b))?(a):(b)
int point[27];
char ch[27];
char d[5001];//开小了
char p[5001];
int dp[2][5001];
int main(){
int n,i,j,k;
while(scanf("%d",&n)!=EOF){
scanf("%s",&ch);
int t;
for(i=0;i scanf("%d",&t);
point[ch[i]-'a']=t;
}
scanf("%s",d+1);
scanf("%s",p+1);
memset(dp,0,sizeof(dp));
int tmp=0;
for(i=1;d[i];i++){
for(j=1;p[j];j++){
if(d[i]==p[j])
dp[tmp][j]=dp[!tmp][j-1]+point[d[i]-'a'];
else{
dp[tmp][j]=MAX(dp[tmp][j-1],dp[!tmp][j]);
}
}
tmp=!tmp;
}
cout< }
return 0;
}

1年前

1
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 16 q. 4.484 s. - webmaster@yulucn.com